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 Tech Support » Unable translating resources Collapse All
Subject Author Date
Dominik Braendlin Mar 11, 2010 - 8:48 AM

Hi Tech Support,


I am translating our software using satellite dll’s. So far everything works fine also using your translated lib resources except! The text of the "Hide" and "Auto Hide" tooltip of the panels can for some reason not be altered. I also tried to directly change the text in the src file "ExtControlBar.cpp" Ln 14693 and Ln 14871 but I still get the same text “Hide” and “Auto Hide”.

 

I am using Prof-UIS v288

Is there some hidden text I am missing?


 


Thanks



Adrian

 

Technical Support Mar 15, 2010 - 5:25 AM

Both MFC and Prof-UIS resource manager will be able to find any resources in your resource DLLs only if they are MFC extension DLLs. They can be linked statically or loaded using the AfxLoadLibrary() MFC API. If your resource DLL are just non-MFC-extension DLLs, then you can make Prof-UIS searching them for resources only if you register your resource DLL handle(s) in the Prof-UIS resource manager using the g_ResourceManager->RscInst_Insert( . . . ) code.

Dominik Braendlin Mar 15, 2010 - 8:23 AM

The following situation works well. I first get the English resources and after LoadBestLanguage I get the language I have selected.


 CString str30048;
 CString str30056;
 
 // English language
 g_ResourceManager->LoadString(str30048, /*IDS_CBNCAREA_CLOSE*/30048);
 g_ResourceManager->LoadString(str30056, /*IDS_EXTTABWND_BTN_AUTOHIDE*/30056);
 
 // call of AfxLoadLibrary()
 m_LanguageSupport.LoadBestLanguage();
 
 // new language
 g_ResourceManager->LoadString(str30048, /*IDS_CBNCAREA_CLOSE*/30048);
 g_ResourceManager->LoadString(str30056, /*IDS_EXTTABWND_BTN_AUTOHIDE*/30056);
 

 

//dllinit.cpp

 

HINSTANCE AFXAPI AfxFindStringResourceHandle(UINT nID)

{
  HINSTANCE hInst;
 
  // first check the main module state
  AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
  if (!pModuleState->m_bSystem)
  {
    hInst = AfxGetResourceHandle();
    if (AtlGetStringResourceImage(hInst, nID) != NULL)
    {
  // found a non-zero string in app
  return hInst;
    }
  }
 
#define IDS_CBNCAREA_CLOSE   30048
#define IDS_EXTTABWND_BTN_AUTOHIDE   30056
#define IDS_CONTENT_EXPAND_TIP   30045

AfxGetResourceHandle in AfxFindStringResourceHandle returns 0x00400000 for ID 30048 and 30056 but 0x03570000 for 30045. 0x03570000 is the handle of the DLL which would be desired also for 30045 and 30056.


 



Any idea?

Technical Support Mar 15, 2010 - 1:36 PM

Unfortunately, we have no idea what is the m_LanguageSupport.LoadBestLanguage(); line of code. Let us assume it’s just AfxLoadLibrary() API invocation and you loaded German resources. Then the next two lines of code will load German strings only if the current thread locale is German. That’s what MFC localization can do. If you use Prof-UIS localization feature, then you can load German strings independently from the Windows/current thread locale setting. Please try to insert the following code immediately after the m_LanguageSupport.LoadBestLanguage(); line of code:

   g_ResourceManager->AllowCustomLang( true );
            g_ResourceManager->SetLangIdDesired( __EXT_MFC_LANG_ID_GERMAN );

Of course, you can use any other __EXT_MFC_LANG_ID_*** language identifier instead.

Dominik Braendlin Mar 18, 2010 - 2:21 AM

The design of my app is a following. One exe for the app using just English resources for MFC and Prof-UIS. No multilingual Resources such as the design of Prof-UIS if the additional languages are switched on. Additional languages are in a satellite dll. One dll per language. If a dll is loaded with AfxLoadLibrary all the resources must be loaded from that dll. The resources from the exe must not be loaded at any time.

As I have mentioned earlier I have moved all the translations per language for the Prof-UIS resources ID 29000 – 32000 Strings, Menu, Dialog and … to the satellite dll.

It seems to me as if the Prof-UIS does not get all its internal resources ID 29000 - 32000 form the same handle once I switch from the exe as the only resource source to a satellite resource only dll using AfxLoadLibrary. As I have tried to explain earlier some Prof-UIS resources are loaded from the dll (using handle 0x03570000) and others are still loaded from the exe (using handle 0x00400000). I don’t know why this is happening. I want the Prof-UIS library to load all the resources from the dll once I have switched to the dll and not from the exe.

I have tried your lines of code and they work


g_ResourceManager->AllowCustomLang( true );

g_ResourceManager->SetLangIdDesired( __EXT_MFC_LANG_ID_GERMAN );


 but I cannot use them in my project because as mentioned I do not want to compile all the Prof-UIS languages into the exe. Only English should be in the exe and if I add an additional language all the additional language resources must be in a satellite dll.

Is there a bug in the Prof-UIS Lib or is it me?

Technical Support Mar 18, 2010 - 12:30 PM

It’s not important where the Prof-UIS resources are stored. The only important thing is whether they are available for MFC style searching algorithm or not. This algorithm searches for the resources which have the same language as specified in Windows locale setting. It does not load resources of any other languages. So, you will need to invoke these lines of code in any case. It’s not important whether you moved Prof-UIS resources into some DLL or not.

Dominik Braendlin Mar 19, 2010 - 1:00 AM

I have added these two lines of code after doing my language switching.



g_ResourceManager->AllowCustomLang(

g_ResourceManager->SetLangIdDesired( m_LanguageSupport.GetCurrentLanguage() );

true );

But the text for "Auto Hide" and "Hide" are still displayed in English when I switch to e.g. German.


My exe has English only resources also the Prof_UIS part is English only. The dll is German only. I still don’t get I why e.g. the Prof-UIS Color dialog is displayed correctly in German also without the above two lines of code and these two "Auto Hide" and "Hide" are not.


Any idea?



 


 

Technical Support Mar 19, 2010 - 12:14 PM

We checked the ..\Prof-UIS\Include\Resources\Resource_deu.rc file and it contains correct string:

        MENUITEM "A&utomatisch verbergen",      ID_EXT_DYN_BAR_AUTO_HIDE

We inserted the following lines of code into the CMainFrame class constructor in the MDIDOCVIEW sample application:
   g_ResourceManager->AllowCustomLang();
            g_ResourceManager->SetLangIdDesired( __EXT_MFC_LANG_ID_GERMAN );

And we saw the Automatisch verbergen text. So, at least, we have this resource string translated and Prof-UIS Resource Manager was able to find and load it. There are couple possible reasons why you didn’t see this text in your application:

1) The m_LanguageSupport.GetCurrentLanguage() returns some language identifier which is not exactly equal to the __EXT_MFC_LANG_ID_GERMAN value that is defined as MAKELANGID(LANG_GERMAN,SUBLANG_GERMAN) where both language and sub-language parts are exactly very important.

2) The German resources are not available for loading because of your resource DLL was not loaded as correct MFC extension DLL. If your resource DLL is MFC extension DLL, then you should load it using AfxLoadLibrary() API. If it’s not an MFC extension DLL, then it should be loaded using the LoadLibrary() and registered in the resource manager using the CExtResourceManager::RscInst_Insert() method.

There are no other reasons to fail loading of localized resources of any type. You can insert the following code into the MDIDOCVIEW sample application and into your application:
   g_ResourceManager->AllowCustomLang();
            g_ResourceManager->SetLangIdDesired( ID_EXT_DYN_BAR_AUTO_HIDE );
CExtSafeString sText;
            g_ResourceManager->LoadString( sText, nId );

This will allow you to debug step by step the resource manager methods. You can enter the CExtResourceManager::LoadString() method, then CExtResourceManager::LoadStringEx() method, then the CExtResourceManager::LoadResourceBufferEx() method, then the CExtResourceManager::LoadResourceBufferSingleLanguage() method. The last method invokes the CExtResourceManager::CExtResourceMemoryBuffer::FindAndLoad() method many times trying to load the string data of the specified language from all the available locations. This will allow you to see all the available resource locations in the running instance of your application and in the MDIDOCVIEW sample application.


Dominik Braendlin Mar 22, 2010 - 2:04 AM

We came a long way but finally I think I have found the problem. When I switch the language I load the language satellite dll with AfxLoadLibrary and then I set the AfxSetResourceHandle to the handle returned from AfxLoadLibrary. After searching in your source code for AfxSetResourceHandle I have found out that there are two locations where this function is called.<o:p></o:p>


It’s in ExtLocalizeation.h Init() LN46 and Free LN 104. I also found a thread in your forum having a customer describing my problem.<o:p></o:p>


http://www.prof-uis.com/prof-uis/tech-support/support-forum/prof-uis-resource-problem-56757.aspx<o:p></o:p>


In some of your classes the class CExtLocalResourceHelper is used which sets the resource handle back to the default one and restors is after completing some task. During that time I get the wrong transaltions.<o:p></o:p>


I have set the CExtLocalResourceHelper::g_bUseResourceHandle = true; and now it works fine.<o:p></o:p>


What side effect could this cause? I am not able to change our way of handling language resources.<o:p></o:p>


I have read the thread http://www.prof-uis.com/prof-uis/tech-support/support-forum/what-to-do-with-cextlocalresourcehelperg_buseresourcehandle-58745.aspx<o:p></o:p>


and it seems as the same situation applies also to our software. <o:p></o:p>


<o:p> </o:p>


 

Technical Support Mar 22, 2010 - 11:39 AM

The CExtLocalResourceHelper class was designed for temporarily resource handle switching. This class is present in Prof-UIS approximately from the first versions release approximately eight years ago. It provides basic localization and resource identifier collision to Prof-UIS source code. There are no side effects with it.
The CExtResourceManager class and the g_ResourceManager global smart pointer variable are the much newer features of Prof-UIS. The resource manager provides better and on the fly switchable localization feature. This feature is easy to use and not available in classic MFC and Win32 applications.
We simply support both resource handle switching and resource manager.

Dominik Braendlin Mar 12, 2010 - 7:17 AM

We provide out own language resource satellite dll’s. That’s why I have turned off all the languages in the prof-uis „resource.rc“ file. In the satellite dll’s we also translate the Prof-UIS Text “ID: 29000 - 32000” the menus and dialogs.

#define __EXT_MFC_NO_RESOURCES_ARABIC_SAUDI_ARABIA

#define __EXT_MFC_NO_RESOURCES_BELARUSIAN

I have found out that if I turn on all the language resources again in the “resource.rc” file the ID IDS_EXTTABWND_BTN_AUTOHIDE translates correct.

I don’t understand why the IDS_EXTTABWND_BTN_AUTOHIDE ID text is not taken from my resource satellite dll but others such as the “Color Dialog” are? Do you call the IDS_EXTTABWND_BTN_AUTOHIDE ID in a different thread other than the main thread?

Thanks

Adrian

Technical Support Mar 12, 2010 - 1:24 AM

The Auto Hide text is loaded from the IDS_EXTTABWND_BTN_AUTOHIDE string resource. The ..\Prof-UIS\Include\Resources\ folder contains a set of *.rc files which are localized Prof-UIS resources. Please find the translation you need and check how the IDS_EXTTABWND_BTN_AUTOHIDE string resource is translated in it. Please use some simple text editor like the standard NOTEPAD.EXE editor provided with any Windows version. If you want to use Visual Studio resource editor for editing Prof-UIS resources, then you should save a copy of the ..\Prof-UIS\Include\Resources\resource.h file somewhere and restore it after editing localized resources in Visual Studio.