1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23: #include <locale.h>
24: #include <libintl.h>
25: #include <stdlib.h>
26: #include <stdio.h>
27:
28: struct data_t
29: {
30: const char *selection;
31: const char *description;
32: };
33:
34: int data_cnt = 2;
35: struct data_t strings[] =
36: {
37: { "String1", N_("First string for testing.") },
38: { "String2", N_("Another string for testing.") }
39: };
40:
41: const int lang_cnt = 3;
42: const char *lang[] = {"lang1", "lang2", "lang3"};
43:
44: int
45: main (void)
46: {
47: int i;
48:
49:
50: unsetenv ("LANGUAGE");
51: unsetenv ("LC_ALL");
52: unsetenv ("LC_MESSAGES");
53: unsetenv ("LC_CTYPE");
54: unsetenv ("LANG");
55: unsetenv ("OUTPUT_CHARSET");
56:
57: textdomain ("tstlang");
58:
59: for (i = 0; i < lang_cnt; ++i)
60: {
61: int j;
62:
63: if (setlocale (LC_ALL, lang[i]) == NULL)
64: setlocale (LC_ALL, "C");
65: bindtextdomain ("tstlang", OBJPFX "domaindir");
66:
67: for (j = 0; j < data_cnt; ++j)
68: printf ("%s - %s\n", strings[j].selection,
69: gettext (strings[j].description));
70: }
71:
72: return 0;
73: }