After doing all the stuff above you should now be able to use the locales that have been created. Here is a simple example program.
/* test.c : a simple test to see if the locales can be loaded, and * used */ #include #include #include main(){ time_t t; struct tm * _t; char buf[256]; time(&t); _t = gmtime(&t); setlocale(LC_TIME,""); strftime(buf,256,"%c",_t); printf("%s\n",buf); }
You can use the locale
program to see what your current locale environment variable settings are.
$ # compile the simple test program above, and run it with $ # some different locale settings $ gcc -s -o Test test.c $ # see what the current locale is : $ locale LANG=POSIX LC_COLLATE="POSIX" LC_CTYPE="POSIX" LC_MONETARY="POSIX" LC_NUMERIC="POSIX" LC_TIME="POSIX" LC_MESSAGES="POSIX" LC_ALL= $ # Ho, hum... we're using the boring C locale $ # let's change to English Canadian: $ export LC_TIME=en_CA $ Test Sat 23 Mar 1996 07:51:49 PM $ # let's try French Canadian: $ export LC_TIME=fr_CA $ Test sam 23 mar 1996 19:55:27