1 /* Test program, used by the intl-setlocale-1 test.
2 Copyright (C) 2000, 2005, 2007, 2013, 2018 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17 /* Contributed to the GNU C Library by
18 Thorsten Kukuk <kukuk@suse.de> and Andreas Jaeger <aj@suse.de>, 2000. */
19
20 #ifdef HAVE_CONFIG_H
21 # include <config.h>
22 #endif
23
24 #include <locale.h>
25 #include <stdlib.h>
26 #include <stdio.h>
27
28 #if USE_SYSTEM_LIBINTL
29 # include <libintl.h>
30 #else
31 /* Make sure we use the included libintl, not the system's one. */
32 # undef _LIBINTL_H
33 # include "libgnuintl.h"
34 #endif
35
36 #define N_(string) string
37
38 struct data_t
39 {
40 const char *selection;
41 const char *description;
42 };
43
44 struct data_t strings[] =
45 {
46 { "String1", N_("First string for testing.") },
47 { "String2", N_("Another string for testing.") }
48 };
49 const int data_cnt = sizeof (strings) / sizeof (strings[0]);
50
51 const char *lang[] = { "de_DE.UTF-8", "fr_FR.UTF-8", "ll_CC" };
52 const int lang_cnt = sizeof (lang) / sizeof (lang[0]);
53
54 int
main(void)55 main (void)
56 {
57 int i;
58
59 /* Clean up environment. */
60 unsetenv ("LANGUAGE");
61 unsetenv ("LC_ALL");
62 unsetenv ("LC_MESSAGES");
63 unsetenv ("LC_CTYPE");
64 unsetenv ("LANG");
65 unsetenv ("OUTPUT_CHARSET");
66
67 textdomain ("tstprog");
68
69 for (i = 0; i < lang_cnt; ++i)
70 {
71 int j;
72
73 if (setlocale (LC_ALL, lang[i]) == NULL)
74 setlocale (LC_ALL, "C");
75
76 bindtextdomain ("tstprog", "in-sl-1");
77
78 for (j = 0; j < data_cnt; ++j)
79 printf ("%s - %s\n", strings[j].selection,
80 gettext (strings[j].description));
81 }
82
83 return 0;
84 }
85