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 » Language switching Collapse All
Subject Author Date
Gevork Odabashyan Aug 23, 2006 - 5:57 AM

Hello

I have some troubles trying to implement runtime language switching. Can you implement and send me a MDI version of your LanguageSwitcher sample?
By the way, is runtime language switching possible without using the CExtCustomizeSite class?

Tthank you.

Technical Support Aug 24, 2006 - 8:15 AM

This is even easier because you do not have to traverse various command trees inside the customize site. Here is a non-customizable MDI application which allows you to switch user interface languages on-the-fly.

Gevork Odabashyan Aug 25, 2006 - 4:03 AM

Hellow

Thanks for your sample. All works, but there is one moment. I want to start my application with last used language. For example, lets set __EXT_MFC_LANG_ID_CHINESE_SIMPLIFIED. I added some lines in your test sample:
In CTestApp::InitInstance(): // lines 93-94
...
    g_ResourceManager->AllowCustomLang( true );
    g_ResourceManager->SetLangIdDesired( __EXT_MFC_LANG_ID_CHINESE_SIMPLIFIED );
...
In CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) // lines 104-106
...
    CString text;
    g_ResourceManager->LoadString(text, IDS_WINDOW);
    m_wndMenuBar.SetMdiWindowPopupName(text);
...
But at start the top level of main menu is __EXT_MFC_LANG_ID_ENGLISH_US, while all it’s submenus are __EXT_MFC_LANG_ID_CHINESE_SIMPLIFIED.
What’s wrong? I sent my patched sample to you. I use "unicode static MFC-static FOSS" build configuration. My environment: WinXP+VS7.1

Thank you.


Technical Support Aug 25, 2006 - 6:57 AM

Did you invoke the ResetLocalizedResources() method after changing the preferred language identifier?

Gevork Odabashyan Aug 25, 2006 - 10:02 AM

Please check the patched sample I sent you. Why I can’t simply set language in CTestApp::InitInstance() before main window creation and invoke properly m_wndMenuBar.SetMdiWindowPopupName() before main menu creation? Why I should invoke ResetLocalizedResources()?

Gevork Odabashyan Aug 25, 2006 - 9:49 AM

But why should I invoke it at the application start? I set language before the main window creation. And there are no any menu at that moment. So I think resources must be loaded properly during main window creation. What’s the difference between creation of all windows with defualt language and with language wich I set?

Technical Support Aug 26, 2006 - 7:31 AM

You should set the language preference at the beginning and before creating Prof-UIS bars only if your application is customizable as in case of LanguageSwitcher. You should change the language preference after all the Prof-UIS windows are created if your application is not customizable like testLanguageMDI. This difference is essential for the customization subsystem only because it should work with the preferred language while initializing.

Gevork Odabashyan Aug 26, 2006 - 3:17 PM

I’m sorry, but can’t understand it. Can you explain me this in detail?

You wrote: "This difference is essential for the customization subsystem only because it should work with the preferred language while initializing". Ok.
So, this dirrence affects only on cusomization subsystem initialization but I don’t need this subsystem at the moment. And the testLanguageMDI sample is not customizable, so the customization subsystem is out of view in this case.

Next, I suppose the CExtResourceManager class must be independent of the customization subsystem, right? As far as I understand, all language-dependent things are controlled by the g_ResourceManager object. All resourses are loaded by the g_ResourceManager using it’s initial language (I suppose it must be equal to g_nLangIdNeutral). So, why I cannot simply set this initial language to my preferred one before any usage of g_ResourceManager? What’s the difference to g_ResourceManager what language it has been initialized with? Why should I create all windows with wrong language and change it to preffred one after that? Is it a architectural feature of Prof-UIS? Or I miss something?



Technical Support Aug 27, 2006 - 9:54 AM

In a non-customizable application like testLanguageMDI, you should restore the preferred language at the end of the CMainFrame::OnCreate() method before the last line return 0. You can invoke the OnUseLanguageChinese() or OnUseLanguageEnglish() methods there and you will see the desired language at start up. Both of these methods perform simple invocations of the resource manager and reset local application’s resources.

Gevork Odabashyan Aug 28, 2006 - 11:39 AM

Next question. If application starts with Russian language as preffered, control bar reposition try causes an assertion:
extpaintmanager.cpp line 29430
As it seems application can’t load docking markers’ bitmaps (paint manager is set to CExtPaintManagerStudio2005 and CExtControlBar::g_eResizablePanelDockingType is set to __RESIZABLE_DOCKING_TYPE_BY_THEME).
If application starts with Russian language as preffered, all works fine.

Technical Support Aug 28, 2006 - 12:29 PM

This assert may occur if you statically link you app with Prof-UIS and forgot to include the Prof-UIS resources in your project, so the bitmap resources are not loaded. Please make sure that you included the following line in your *.rc2 file:

#if ( !(defined _AFXDLL && !defined __STATPROFUIS_WITH_DLLMFC__) )
    #include <Resources/Resource.rc>
#endif
You can read more about this in the FAQ How to link statically with Prof-UIS?

Gevork Odabashyan Aug 28, 2006 - 11:49 AM

Sorry, my last sentence I wanted to say that if preffered language is set to Endlish (not Russian), application works correctly.