]>
Commit | Line | Data |
---|---|---|
cdfb970d | 1 | /* Test of the gettext functions. |
688903eb | 2 | Copyright (C) 2000-2018 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 | 17 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
18 | License along with the GNU C Library; if not, see |
19 | <http://www.gnu.org/licenses/>. */ | |
cdfb970d UD |
20 | |
21 | ||
22 | #include <locale.h> | |
23 | #include <libintl.h> | |
24 | #include <stdlib.h> | |
25 | #include <stdio.h> | |
26 | ||
7c3018f9 ZW |
27 | #define N_(msgid) msgid |
28 | ||
111bb972 UD |
29 | struct data_t |
30 | { | |
cdfb970d UD |
31 | const char *selection; |
32 | const char *description; | |
33 | }; | |
34 | ||
35 | int data_cnt = 2; | |
36 | struct data_t strings[] = | |
111bb972 UD |
37 | { |
38 | { "String1", N_("First string for testing.") }, | |
39 | { "String2", N_("Another string for testing.") } | |
cdfb970d UD |
40 | }; |
41 | ||
42 | const int lang_cnt = 3; | |
43 | const char *lang[] = {"lang1", "lang2", "lang3"}; | |
44 | ||
29955b5d AS |
45 | static int |
46 | do_test (void) | |
cdfb970d UD |
47 | { |
48 | int i; | |
49 | ||
50 | /* Clean up environment. */ | |
51 | unsetenv ("LANGUAGE"); | |
52 | unsetenv ("LC_ALL"); | |
53 | unsetenv ("LC_MESSAGES"); | |
54 | unsetenv ("LC_CTYPE"); | |
55 | unsetenv ("LANG"); | |
56 | unsetenv ("OUTPUT_CHARSET"); | |
111bb972 | 57 | |
cdfb970d UD |
58 | textdomain ("tstlang"); |
59 | ||
60 | for (i = 0; i < lang_cnt; ++i) | |
61 | { | |
62 | int j; | |
63 | ||
111bb972 UD |
64 | if (setlocale (LC_ALL, lang[i]) == NULL) |
65 | setlocale (LC_ALL, "C"); | |
cdfb970d UD |
66 | bindtextdomain ("tstlang", OBJPFX "domaindir"); |
67 | ||
68 | for (j = 0; j < data_cnt; ++j) | |
111bb972 UD |
69 | printf ("%s - %s\n", strings[j].selection, |
70 | gettext (strings[j].description)); | |
cdfb970d UD |
71 | } |
72 | ||
73 | return 0; | |
74 | } | |
29955b5d AS |
75 | |
76 | #define TEST_FUNCTION do_test () | |
77 | #include "../test-skeleton.c" |