Views User Guides > Foundation > Internationalization > Creating a Program to Run in a Localized Environment
Creating a Program to Run in a Localized Environment
When creating a program that you intend to use in an internationalized environment, you code as you normally would for any other program. You must make sure, however, that you call the IlvSetLocale global function at the beginning of your program. This call should appear before creating an instance of IlvDisplay. The IlvSetLocale call is necessary for Views to set up the underlying information it needs to run correctly in the default locale environment.
Note:  If you do not have a call to IlvSetLocale in your program, the localized messages will not appear on the screen and multibyte support will not be enabled. Your program will behave as if you are running in the C locale, thus displaying only English messages.
The following example shows a simple program that is ready for an internationalized environment, meaning that the program can run in different languages. Notice the IlvSetLocale() call at the beginning of the program.
#include <ilviews/gadgets/gadcont.h>
#include <ilviews/gadgets/textfd.h>
#include <stdio.h>
 
static void
Quit(IlvView*, IlvAny)
{
IlvExit(0);
}
 
int main (int argc, char* argv[])
{
if (!IlvSetLocale()) {
printf("Falling back to the C locale.\n");
}
 
IlvDisplay* display = new IlvDisplay("Test", 0, argc, argv);
IlvRect rect(20,20,250,80);
IlvGadgetContainer* cont = new IlvGadgetContainer(display, "Container", "Container", rect);
cont->setDestroyCallback(Quit, 0);
IlvRect rect1(10,10,220,50);
IlvTextField* tf = new IlvTextField(display, "This is a text field.",
rect1);
cont->addObject(tf);
IlvMainLoop();
return 0;
}
Published date: 05/24/2022
Last modified date: 02/24/2022