Imported Upstream version 0.18.3.2
[platform/upstream/gettext.git] / gettext-tools / tests / gettext-3-prg.c
1 /* Test program, used by the gettext-3 test.
2    Copyright (C) 2000, 2005, 2007 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 <http://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 /* Make sure we use the included libintl, not the system's one. */
29 #undef _LIBINTL_H
30 #include "libgnuintl.h"
31
32 #define N_(string) string
33
34 struct data_t
35 {
36   const char *selection;
37   const char *description;
38 };
39
40 struct data_t strings[] =
41 {
42   { "String1", N_("First string for testing.") },
43   { "String2", N_("Another string for testing.") }
44 };
45 const int data_cnt = sizeof (strings) / sizeof (strings[0]);
46
47 const char *lang[] = { "de_DE", "fr_FR", "ll_CC" };
48 const int lang_cnt = sizeof (lang) / sizeof (lang[0]);
49
50 int
51 main (void)
52 {
53   int i;
54
55   /* Clean up environment.  */
56   unsetenv ("LANGUAGE");
57   unsetenv ("LC_ALL");
58   unsetenv ("LC_MESSAGES");
59   unsetenv ("LC_CTYPE");
60   unsetenv ("LANG");
61   unsetenv ("OUTPUT_CHARSET");
62
63   textdomain ("tstlang");
64
65   for (i = 0; i < lang_cnt; ++i)
66     {
67       int j;
68
69       if (setlocale (LC_ALL, lang[i]) == NULL)
70         setlocale (LC_ALL, "C");
71
72       bindtextdomain ("tstlang", "gt-3");
73
74       for (j = 0; j < data_cnt; ++j)
75         printf ("%s - %s\n", strings[j].selection,
76                 gettext (strings[j].description));
77     }
78
79   return 0;
80 }