Foundation > Internationalization > Localized Message Database Files in Rogue Wave Views > How to Dynamically Change Your Display Language
 
How to Dynamically Change Your Display Language
You can dynamically change your display language. You simply need to call IlvDisplay::setCurrentLanguage on the display. Rogue Wave Views will reload automatically all the data files that you currently have loaded and display the new language. In order to do this, you have to provide the localized versions of these files and they must be available on your system.
Note: If you plan to switch languages, you need to start your application in the strongest encoding. For example, if you plan to switch between French and English, start your application in French. If however, you want your application to show English messages when started, override your start-up display language by using the ILVLANG environment variable or the lang resource on Windows.
Let's say you have created an application where all the messages are defined in a file named my_messages.dbm.
If display is your display, just load this file at the beginning of your application through a call to:
display->getDatabase()->read("my_messages.dbm", display);
If you have started your program in a French locale, Rogue Wave Views will load the file located in locale/fr_FR.ISO-8859-1/my_messages.dbm.
Now, to change your display language, just call IlvDisplay::setCurrentLanguage with the new language you want. For example, if you want your display to be in Italian, call:
display->setCurrentLanguage(IlGetSymbol("it_IT"));
Rogue Wave Views will automatically load the file located in:
locale/it_IT.ISO-8859-1/my_messages.dbm
It will also load all the other data files that are already open.
To go back to French, call IlvDisplay::setCurrentLanguage again as follows:
display->setCurrentLanguage(IlGetSymbol("fr_FR"));
Note: This can only be done if the encodings are compatible.
The sample that you can find in samples/foundation/i18n/changelang is an illustration of this feature.

Version 6.1
Copyright © 2016, Rogue Wave Software, Inc. All Rights Reserved.