Click here to Skip to main content
Click here to Skip to main content

Multilingual Application - Change Application Language

By , 17 Nov 1999
 

Introduction

Developing applications supporting multiple languages has always been a drag. With the possibility of including several languages into the rc file of a project, the problem is not entirely solved: The operating system is used as a base and decides what language your application is working with.

If as example, the resources contain English and German, the application will use the English resources on an American or British Windows system, and German on a German or Swiss (German) Windows version. Other language versions of Windows will use the default language (English in most cases).

This behavior is acceptable in most cases, but can cause some headaches: A French speaking person might prefer the German version of your application, but gets by default the English version. Under Windows NT and Windows 2000, there is a simple way of adding the functionality for switching between languages.

Please note: This will only work under NT 3.51 and Windows 2000. There were some problems using NT 4.0 SP3 (and earlier?) reported, but I could not confirm them.

Step 1.

Add the desired languages to your resources.

resources

Step 2.

Enhance your code as follows:

 // Place this code in InitInstance()
 m_lang = GetProfileInt("General","Language",0);
  if (m_lang == 0) {
    // switch language to english
    ::SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH,
                       SUBLANG_DEFAULT),SORT_DEFAULT));
  }
  else {
    // switch language to german
    ::SetThreadLocale(MAKELCID(MAKELANGID(LANG_GERMAN,
                       SUBLANG_DEFAULT),SORT_DEFAULT));
  }
  //
  //
  // Add a menu or a toolbar button and attach this method 

  void CLanguageApp::OnLanguageTogglelanguage() 
  {
    if (m_lang == 0) {
      WriteProfileInt("General","Language",1);
    }
    else {
      WriteProfileInt("General","Language",0);
    }
    AfxMessageBox(IDS_RESTART); // tell the user to restart the application
  }

//

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Daniel Zuppinger
Chief Technology Officer
Switzerland Switzerland
Member
Professional IT developer since 1983. First projects with Cobol, then Pascal, Modula2, C and since Visual C++ 1.0 also with C++. Works since 1986 as Consultant, between 1990 and 2008 for Infobrain in Switzerland, currently employed by enValue (also Switzerland).
Current field is the project management and development of software for Bank applications.
Married, two daughters, Hobbies : Paragliding, Orienteering, Mountainbiking, Photography

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionI can't use in Russianmembercoma3232 Dec '07 - 0:28 
I had built this source.
I can't look want language in Russian
How do I am?
GeneralPlease helpmembersreejith ss nair18 Sep '05 - 21:28 
Good Article.
 
I have a small doubt regarding Globalization/Localization. Hope you can help me out.
I have a web form application where i need to provide more than 50 different localized resource supports. Apart from this, my application supports rich use of stored data (Sql Server Database) and obviously have few list of Listing controls (Repeater , Grid etc).
 
My requirement comes like this,
 
a) I need to provide full localized language support in all data which is displaying in each and every page. Regardless of, the name of controls, content of controls etc. To be concise, which ever text that i am displaying through page, need to be localized based on user selected language.
 
b) Each and every setup needs to contain all supported languages. So user can switch and view content of site in different language.
 
I stuck in,
 
1) I am not sure how to localize stored data in database.
2) How will I give or from where i generate localized information for all supported language.
 
It would be grate if you can help me out through your valid comments.

 
Sreejith Nair
[ My Articles ]
QuestionHow about using Frenchmemberashish kumar patel1 Aug '05 - 19:19 
I have tried ur sample application. It doesn't seem to work for other languages.
Supposing French, Spanish etc.
 
Also when i tried to make my own application German also does not work.
 
However in ur application the to and fro b/w german and english is perfect.
 
Are there some settigs in the application
 
Thanks
Blush | :O
AnswerRe: How about using FrenchmemberOphir15 Feb '06 - 10:46 
The problem lays on the process of creating the German DLL. The technique is OK but how do you compile Chinese resources in an English locale development computer?
GeneralProblem with language=English(USA)memberachimschoen24 Apr '05 - 20:53 
This program works perfectly as long you are not setting the language to English(USA) on your machine. On my german version of XP this show up the dialog in germany (independent of registry setting). If I set the system language to English(Zimbabwe) it will work.
 
Is that a odd behaviour of XP ???

 
Achim
GeneralGlobalization using .NET and Oracle 10gmemberashit_barot21 Mar '05 - 18:58 
Hi friends,
 
I m using Visual Basic .NET and Oracle 10g for Globalization of our product. I am able to change the static text to particular language. Now my problem is i can't convert data which comes from Oracle database into particular language. Any tool/provider is required for that?
 
Can anybody guide me in that aspect???
 
ashit barot
GeneralMircrosoft advise against this on 2000/XPmemberObliterator15 Dec '04 - 3:42 
Just looking at the MS documentation for SetThreadLocale.
In the remarks they advise against the use of this call for this purpose on Win 2000/XP. Any ideas why?
Quote: Windows 2000/XP: Do not use SetThreadLocale to select a UI language.<br>To select the proper resource that is defined with a LANGUAGE statement, use FindResourceEx.
Obviously FindResourceEx is completely unsuited to this purpose without replacing every single call to a resource in your code!
 
--
 
The Obliterator
GeneralUse external language packs instead of DLLs for supporting multilingualmemberHerman Kwan9 Aug '02 - 14:14 
Just like Netants, FlashGet, Tweak-XP, PatchWise Free, etc. More and more applications use external language packs (*.ini or *.lng) instead of DLLs for supporting multilingual. It’s not necessary to recompile the whole project because the language packs can be added or modified dynamically. Absolutely, it's easy to translate and maintain the external language packs which are just like an INI-like text file. Smile | :)
 
Here's a software development libraries named "LocWise" can easy help you provide multilingual support for Win32 software using external language packs.
 
Check TUCOWS for details. http://www.tucows.com/system/preview/262299.html
 
Or, visit its home page in http://www.hanmen.com/locwise

 
HANMEN.com - Multiligual Development & Patch Utilities
QuestionHow about the Win95/98/MEmembersandy16 Oct '01 - 4:56 
Hi,
 
If I want to switch the language in the Win95/98/ME, how I can do?
 
Thanks a lot!
 
sandy
AnswerRe: How about the Win95/98/MEmemberrudie7 Jan '03 - 22:36 
You cant. MS will probably state at the end of the Knowledge Base article:
"This behaviour is by design".
 
Yeah right...Sleepy | :zzz:

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 18 Nov 1999
Article Copyright 1999 by Daniel Zuppinger
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid