すべて済めば、作成された locale を使うことができるでしょう。以下は単純 な例題プログラムです。
/* test.c : a simple test to see if the locales can be loaded, and
* used */
#include <locale.h>
#include <stdio.h>
#include <time.h>
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);
}
現在の locale 環境変数設定がどうなっているかを locale プログラムを使っ て見ることができます。
$ # 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