FlorianJaeger
asked on
MFC Gui in different languages
I have a GUI (not very complex, just one dialog) and I would like to have it in two languages, notably German and English.
I might also do this for more complicated GUIs if it turns out not to be too difficult.
Now ... what would the easiest thing to do be? I know that one is supposed to use the string tables - but:
* How do I add the strings in differnet languages
* How do I determine what language will be used
* How do I specify what variables/strings to use in the static controls for example?
* How do I use the string table in my code such as in custom messagebox() calls ...
Thank you!
I might also do this for more complicated GUIs if it turns out not to be too difficult.
Now ... what would the easiest thing to do be? I know that one is supposed to use the string tables - but:
* How do I add the strings in differnet languages
* How do I determine what language will be used
* How do I specify what variables/strings to use in the static controls for example?
* How do I use the string table in my code such as in custom messagebox() calls ...
Thank you!
ASKER
Isn't it possible to do this without creating a DLL and have all this information embedded in the exe file?
Yeah it is but you have this problem...
if ( GERMAN )
LoadString ( IDR_GERMAN_WELCOME_MSG );
else
LoadString ( IDR_ENGLISH_WELCOME_MSG );
Instead of
LoadString ( IDR_WELCOME_MSG );
If you dont want to do the LoadDll thing then add all the strings to your resource and two dialog templates. Then based on the language you need to make an if decision when ever they are needed.
ASKER
Thanks, can I not have two string tables? I tried to insert another string table but that didn't work at all.
I really have no experience with string tables ... :(
I really have no experience with string tables ... :(
You can right Click on the String table itself and choose 'Insert Copy' then pick a language.
ASKER
Aha! Thanks - could have figured that out myself.
OK, next question :)
So far I have only created GUIs that have one language, so when I insert a static control I just type the text in.
Now how do I do that know? Obviously I don't want to use static text anymore ...
... and the same goes for message boxes that display errors / warnings ...
Usually I would do:
MessageBox("Error 3 occured", "Error", MB_ICONSTOP)
.. but what do I do know?
And the final question: How do I determine which language to use???
Thanks a lot!!
OK, next question :)
So far I have only created GUIs that have one language, so when I insert a static control I just type the text in.
Now how do I do that know? Obviously I don't want to use static text anymore ...
... and the same goes for message boxes that display errors / warnings ...
Usually I would do:
MessageBox("Error 3 occured", "Error", MB_ICONSTOP)
.. but what do I do know?
And the final question: How do I determine which language to use???
Thanks a lot!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have question regarding the automatic choice of locale. When I copy the string table I can choose between German(Germany), German(Austria) and German(Switzerland). I certainly don't want to create three string tables for the same language.
What do you think happens if I create a string table for German (Germany) and somebody in Switzerland launches the GUI?
Just curious ... maybe it doesn't matter which one I choose?
Thanks so far !
What do you think happens if I create a string table for German (Germany) and somebody in Switzerland launches the GUI?
Just curious ... maybe it doesn't matter which one I choose?
Thanks so far !
You could change the Locale of you comp temporarily adn see what happens :)
Gutten Dag!
ASKER
CString csText;
csText.LoadString ( IDS_STATICLABEL1 );
m_staticLabel1.SetWindowTe xt ( csText );
seems to work fairly well, this way I can also let the user change the language at runtime.
However creating a control variable for every single static control seems like a big overhead - that's a lot of work to do!
It doesn't really matter for the current project since it's just one dialog but I was thinking about doing it for another one as well and that has about 10 dialogs ... is there not an easier way??
Thanks!
csText.LoadString ( IDS_STATICLABEL1 );
m_staticLabel1.SetWindowTe
seems to work fairly well, this way I can also let the user change the language at runtime.
However creating a control variable for every single static control seems like a big overhead - that's a lot of work to do!
It doesn't really matter for the current project since it's just one dialog but I was thinking about doing it for another one as well and that has about 10 dialogs ... is there not an easier way??
Thanks!
ASKER
William,
There is another thing that I just realized, with the method were I don't use the DLLs I can't really determine which string table to use, right? It's determined by the OS depending on the OS language. That's not that good as I would like to give the user the option of changing the language (for example run it in English no matter what OS language they have installed).
Is there a fix for that?
Btw, changing the locale doesn't do anything, seems as if you need to run a German OS (for example) for the different string table to be used.
This whole thing seems more complicated than I thought (per usual ...)
Thanks ...
There is another thing that I just realized, with the method were I don't use the DLLs I can't really determine which string table to use, right? It's determined by the OS depending on the OS language. That's not that good as I would like to give the user the option of changing the language (for example run it in English no matter what OS language they have installed).
Is there a fix for that?
Btw, changing the locale doesn't do anything, seems as if you need to run a German OS (for example) for the different string table to be used.
This whole thing seems more complicated than I thought (per usual ...)
Thanks ...
I'm afraid so..
'Operating system is responsible for loading the language specific resource'
You can change locale via the control panel.
Looks like you will have to support two sets of dialogs and strings...yes it's that difficult :(
Here is an interesting article that you may find useful.
http://www.codeproject.com/tips/internationalization.asp?target=globalization
'Operating system is responsible for loading the language specific resource'
You can change locale via the control panel.
Looks like you will have to support two sets of dialogs and strings...yes it's that difficult :(
Here is an interesting article that you may find useful.
http://www.codeproject.com/tips/internationalization.asp?target=globalization
ASKER
Funny, I just looked at that article yesterday ... didn't find it too useful though.
I really could use the
CString csText;
csText.LoadString ( IDS_STATICLABEL1 );
m_staticLabel1.SetWindowTe xt ( csText );
approach - and just add a button where the user can prevent the code from looking at the alternative string table - just leaving the dialog the way it is.
I think that would be a good decision.
And, as I said earlier, changing the locale didn't have any effect and I'm convinced that you need to have a OS in a different language for that to work - difficult to test though ...
What do you think? :-)
I really could use the
CString csText;
csText.LoadString ( IDS_STATICLABEL1 );
m_staticLabel1.SetWindowTe
approach - and just add a button where the user can prevent the code from looking at the alternative string table - just leaving the dialog the way it is.
I think that would be a good decision.
And, as I said earlier, changing the locale didn't have any effect and I'm convinced that you need to have a OS in a different language for that to work - difficult to test though ...
What do you think? :-)
Check this out
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/loadkeyboardlayout.asp
Apparently this works on a per process basis
I think you use MAKELANGID
Then call LoadKeyBoardLayout ();
Worth a try
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/loadkeyboardlayout.asp
Apparently this works on a per process basis
I think you use MAKELANGID
Then call LoadKeyBoardLayout ();
Worth a try
ASKER
Don't worry about that too much please, a friend of mine lives in Austria and can check that out for me.
I also have a german version of NT4 somewhere that I can use once I get back to my office.
I think I'll just go that way so that would be good for now.
Thanks for all your help!
I also have a german version of NT4 somewhere that I can use once I get back to my office.
I think I'll just go that way so that would be good for now.
Thanks for all your help!
You might create two resource DLL's
Each contains the Strings and Template for your Dialog in a different language.
At Runtime based on the language (Use GetLocale) you call LoadLibrary on the appropriate DLL. Then using FindResource you load your template. Using LoadString you load your strings.
Should you choose to support more languages at at later date simply create another DLL.