Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Internationalization (Language switcher) Collapse All
Subject Author Date
Roberto Manes May 12, 2006 - 9:01 AM

Dear Sirs
I’m developing a MDI application and I’m still using Prof-UIS 2.30. I followed the "Language Switcher" example in order to change the language of my application on the fly but nothing happens. My application comes with three different language resources files. I’ve tryed with the SetThreadLocal function and of course it works. My application works with two different document types, the standard mainframe and one child frame for each document type. Each frame cames with a its own menu. Toolbar are shared between the two document types. Here follows breifly a summary of the functions included into my ResetLocalizedResources() method just to help you to understand what I’m missing. Thanks in advance for your help.

    VERIFY( _SetStatusBarIndicators() );
    VERIFY( _UpdateCommandManager() );
    _ConfigureCustomizeSite();

//#ifdef CUSTOMIZE_APP
    CExtCustomizeSite::MenuInfoRemove();
    CWinApp * pApp = ::AfxGetApp();

    VERIFY(
        g_CmdManager->SetBasicCommands(
        pApp->m_pszProfileName,
        g_statBasicCommands)
        );

    VERIFY(
        CExtCustomizeSite::MenuInfoAdd(
        this,
        _T("Default"),
        IDR_MAINFRAME,
        true,
        false,
        RUNTIME_CLASS(CMainFrame)
        )
    );


    VERIFY(
        CExtCustomizeSite::MenuInfoLoadAccelTable(
            _T("Default"),
            IDR_MAINFRAME
            )
        );

    VERIFY(
        CExtCustomizeSite::MenuInfoAdd(
        this,
        _T("cways"),
        IDR_MAINFRAME_CWAYS,
        false,
        false,
        RUNTIME_CLASS(CColorWayDoc),
        RUNTIME_CLASS(CChildFrameCway), // custom MDI child frame
        RUNTIME_CLASS(CColorWayView)
        )
    );

    VERIFY(
        CExtCustomizeSite::MenuInfoLoadAccelTable(
            _T("cways"),
            IDR_MAINFRAME_CWAYS
            )
        );

    VERIFY(
        CExtCustomizeSite::MenuInfoAdd(
        this,
        _T("atlas"),
        IDR_MAINFRAME_ATLAS,
        false,
        false,
        RUNTIME_CLASS(CColorAtlasDoc),
        RUNTIME_CLASS(CChildFrameAtlas), // custom MDI child frame
        RUNTIME_CLASS(CColorAtlasView)
        )
    );

    VERIFY(
        CExtCustomizeSite::MenuInfoLoadAccelTable(
            _T("atlas"),
            IDR_MAINFRAME_ATLAS
            )
        );

    CExtCustomizeSite::MenuInfoGetDefault()->AccelTableReset();
    CExtCustomizeSite::OnUpdateAccelGlobalInfo();
//#endif

    _ResetAllCommandTrees();
    m_wndMenuBar.UpdateMenuBar();
    RecalcLayout();
    CExtControlBar::stat_RecalcBarMetrics( this );
    CExtControlBar::stat_RedrawFloatingFrames( this );

    SendMessage( WM_SETMESSAGESTRING, AFX_IDS_IDLEMESSAGE );

Technical Support May 12, 2006 - 11:42 AM

Your source code looks correct. We may only guess you have a problem because of some typo somewhere. Please check whether the code like as follows is invoked before your ResetLocalizedResources() method is called:

g_ResourceManager->AllowCustomLang();
g_ResourceManager->SetLangIdDesired( . . . );
You can also send your project to us so we can find out what’s wrong.

Roberto Manes May 15, 2006 - 8:03 AM

Dear Sirs.
I apologize because I forgot to call the AllowCustomLang() method. The problem I’m facing now is that the main menu now comes with the correct language but all the popup menus are still in the wrong language. Also the titles and buttons of CExtResizablePropertySheet objects are wrong. Any idea ? Thanks

Technical Support May 15, 2006 - 10:22 AM

Please invoke the Customize dialog and reset the menu bar by selecting Menu Bar in the toolbars’ list box and clicking the Reset button. If the menus have the correct language after that, then your language switching code does not reset the menu bar’s command tree nodes. If the menu bar’s menus still have an incorrect language, then your language switching code does not update the command manager correctly.

Roberto Manes May 15, 2006 - 12:52 PM

The menus have the correct language after that. Here is what I do in order to reset the menu bar’s command tree nodes
As far as I change the language id I call the following method _ResetAllCommandTrees() which is listed below. Please let me know what I’m missing
Regards

void CMainFrame::_ResetAllCommandTrees()
{
CPtrList _listBarsBasic, _listBarsUser;
    CExtCustomizeSite::BuildToolbarLists(
        &_listBarsBasic,
        &_listBarsUser
        );
POSITION pos;
    for( pos = _listBarsBasic.GetHeadPosition(); pos != NULL; )
    {
        CExtToolControlBar * pToolBar = (CExtToolControlBar *)
            _listBarsBasic.GetNext( pos );
        ASSERT_VALID( pToolBar );
        ASSERT_KINDOF( CExtToolControlBar, pToolBar );
        if( pToolBar->IsKindOf( RUNTIME_CLASS(CExtMenuControlBar) ) )
            continue;
        CExtCustomizeCmdTreeNode * pNode =
            CExtCustomizeSite::GetToolbarCmdNode( pToolBar, true );
        ASSERT_VALID( pNode );
        ASSERT_KINDOF( CExtCustomizeCmdTreeNode, pNode );
        _ReloadNodeFromCommandManager( pNode, false, true );
        pNode =
            CExtCustomizeSite::GetToolbarCmdNode( pToolBar, false );
        ASSERT_VALID( pNode );
        ASSERT_KINDOF( CExtCustomizeCmdTreeNode, pNode );
        _ReloadNodeFromCommandManager( pNode, false, true );
        CExtCustomizeSite::BarReset( pToolBar, ! pToolBar->IsFloating() );
    } // for( pos = _listBarsBasic.GetHeadPosition(); pos != NULL; )
    for( pos = _listBarsUser.GetHeadPosition(); pos != NULL; )
    {
        CExtToolControlBar * pToolBar = (CExtToolControlBar *)
            _listBarsUser.GetNext( pos );
        ASSERT_VALID( pToolBar );
        ASSERT_KINDOF( CExtToolControlBar, pToolBar );
        CExtCustomizeCmdTreeNode * pNode =
            CExtCustomizeSite::GetToolbarCmdNode( pToolBar, false );
        ASSERT_VALID( pNode );
        ASSERT_KINDOF( CExtCustomizeCmdTreeNode, pNode );
        _ReloadNodeFromCommandManager( pNode, false, true );
        CExtCustomizeSite::BarReset( pToolBar, ! pToolBar->IsFloating() );
    } // for( pos = _listBarsBasic.GetHeadPosition(); pos != NULL; )
}

//
/////////////////////////////////////////////
void CMainFrame::_ReloadNodeFromCommandManager(
    CExtCustomizeCmdTreeNode * pNode,
    bool bReloadNode,
    bool bReloadChildren
    )
{
    ASSERT_VALID( pNode );
    ASSERT_KINDOF( CExtCustomizeCmdTreeNode, pNode );
    if( bReloadNode )
    {
        CWinApp * pApp = ::AfxGetApp();
        ASSERT( pApp != NULL );
        ASSERT( pApp->m_pszRegistryKey != NULL );
        ASSERT( pApp->m_pszRegistryKey[0] != _T(’\0’) );
        ASSERT( pApp->m_pszProfileName != NULL );
        ASSERT( pApp->m_pszProfileName[0] != _T(’\0’) );
        ASSERT( pApp->m_pszProfileName != NULL );
        UINT nCmdID = pNode->GetCmdID( false );
        CExtCmdItem * pCmdItem =
        g_CmdManager->CmdGetPtr(
            pApp->m_pszProfileName,
            nCmdID
            );
        ASSERT( pCmdItem != NULL );
        if( !pCmdItem ) return;
        pNode->ResetIcon( pCmdItem );
        pNode->AssignCmdProps( pCmdItem );
        if( g_CmdManager->CmdGetIconPtr(
                pApp->m_pszProfileName,
                nCmdID
                ) != NULL
            )
            pNode->ModifyFlags( __ECTN_DISPLAY_DEFAULT_STYLE /*__ECTN_DISPLAY_TEXT_AND_IMAGE */);
    } // if( bReloadNode )
    if( bReloadChildren )
    {
        INT nIdx, nCount = pNode->GetNodeCount();
        for( nIdx = 0; nIdx < nCount; nIdx ++ )
        {
            CExtCustomizeCmdTreeNode * pChildren =
                pNode->ElementAt( nIdx );
            ASSERT_VALID( pChildren );
            ASSERT_KINDOF( CExtCustomizeCmdTreeNode, pChildren );
            _ReloadNodeFromCommandManager(
                pChildren,
                true,
                true
                );
        } // for( nIdx = 0; nIdx < nCount; nIdx ++ )
    } // if( bReloadChildren )
}

Technical Support May 16, 2006 - 9:54 AM

There is only one difference between your application and the LanguageSwitcher sample project. Your application is MDI while our sample is SDI. We guess the problem is linked to this difference. Please let us take a look at your CMainFrame::ResetLocalizedResources() method.

Roberto Manes May 16, 2006 - 10:12 AM

In the first contact we have got I supplyed the ResetLocalizedResources() method which makes a call as you can see to the ResetAllCommandTrees() method at the end. So I don’t really know what you would need to have a look in order to help. If you have any other suggestion it would be appreciated. In the mean time I will try to do some test onto a new multidocument application

Technical Support May 16, 2006 - 12:29 PM

We are sorry for the incorrect query in our last post. It’s our fault. At this moment we can see two possible ways to help you resolve the issue:

1) We can analyze your project and fix the problem.

2) We can convert the LanguageSwitcher sample into MDI and sent it to you.

The first way is preferable but may require some effort from you in order to create some stripped version of your project.