]>
Commit | Line | Data |
---|---|---|
cdfb970d UD |
1 | /* Test of the gettext functions. |
2 | Copyright (C) 2000 Free Software Foundation, Inc. | |
41bdb6e2 | 3 | This file is part of the GNU C Library. |
cdfb970d UD |
4 | Contributed by Thorsten Kukuk <kukuk@suse.de> and |
5 | Andreas Jaeger <aj@suse.de>, 2000. | |
6 | ||
7 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
8 | modify it under the terms of the GNU Lesser General Public |
9 | License as published by the Free Software Foundation; either | |
10 | version 2.1 of the License, or (at your option) any later version. | |
cdfb970d UD |
11 | |
12 | The GNU C Library is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 15 | Lesser General Public License for more details. |
cdfb970d | 16 | |
41bdb6e2 AJ |
17 | You should have received a copy of the GNU Lesser General Public |
18 | License along with the GNU C Library; if not, write to the Free | |
19 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
20 | 02111-1307 USA. */ | |
cdfb970d UD |
21 | |
22 | ||
23 | #include <locale.h> | |
24 | #include <libintl.h> | |
25 | #include <stdlib.h> | |
26 | #include <stdio.h> | |
27 | ||
111bb972 UD |
28 | struct data_t |
29 | { | |
cdfb970d UD |
30 | const char *selection; |
31 | const char *description; | |
32 | }; | |
33 | ||
34 | int data_cnt = 2; | |
35 | struct data_t strings[] = | |
111bb972 UD |
36 | { |
37 | { "String1", N_("First string for testing.") }, | |
38 | { "String2", N_("Another string for testing.") } | |
cdfb970d UD |
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 | /* Clean up environment. */ | |
50 | unsetenv ("LANGUAGE"); | |
51 | unsetenv ("LC_ALL"); | |
52 | unsetenv ("LC_MESSAGES"); | |
53 | unsetenv ("LC_CTYPE"); | |
54 | unsetenv ("LANG"); | |
55 | unsetenv ("OUTPUT_CHARSET"); | |
111bb972 | 56 | |
cdfb970d UD |
57 | textdomain ("tstlang"); |
58 | ||
59 | for (i = 0; i < lang_cnt; ++i) | |
60 | { | |
61 | int j; | |
62 | ||
111bb972 UD |
63 | if (setlocale (LC_ALL, lang[i]) == NULL) |
64 | setlocale (LC_ALL, "C"); | |
cdfb970d UD |
65 | bindtextdomain ("tstlang", OBJPFX "domaindir"); |
66 | ||
67 | for (j = 0; j < data_cnt; ++j) | |
111bb972 UD |
68 | printf ("%s - %s\n", strings[j].selection, |
69 | gettext (strings[j].description)); | |
cdfb970d UD |
70 | } |
71 | ||
72 | return 0; | |
73 | } |