xref: /netbsd-src/external/gpl2/gettext/dist/gettext-tools/tests/gettext-3-prg.c (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
1 /* Test program, used by the gettext-3 test.
2    Copyright (C) 2000, 2005 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 2, or (at your option)
7    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, write to the Free Software Foundation,
16    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
17 
18 /* Contributed to the GNU C Library by
19    Thorsten Kukuk <kukuk@suse.de> and Andreas Jaeger <aj@suse.de>, 2000.  */
20 
21 #ifdef HAVE_CONFIG_H
22 # include <config.h>
23 #endif
24 
25 #include <locale.h>
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include "setenv.h"
29 
30 /* Make sure we use the included libintl, not the system's one. */
31 #undef _LIBINTL_H
32 #include "libgnuintl.h"
33 
34 #define N_(string) string
35 
36 struct data_t
37 {
38   const char *selection;
39   const char *description;
40 };
41 
42 struct data_t strings[] =
43 {
44   { "String1", N_("First string for testing.") },
45   { "String2", N_("Another string for testing.") }
46 };
47 const int data_cnt = sizeof (strings) / sizeof (strings[0]);
48 
49 const char *lang[] = { "de_DE", "fr_FR", "ll_CC" };
50 const int lang_cnt = sizeof (lang) / sizeof (lang[0]);
51 
52 int
main(void)53 main (void)
54 {
55   int i;
56 
57   /* Clean up environment.  */
58   unsetenv ("LANGUAGE");
59   unsetenv ("LC_ALL");
60   unsetenv ("LC_MESSAGES");
61   unsetenv ("LC_CTYPE");
62   unsetenv ("LANG");
63   unsetenv ("OUTPUT_CHARSET");
64 
65   textdomain ("tstlang");
66 
67   for (i = 0; i < lang_cnt; ++i)
68     {
69       int j;
70 
71       if (setlocale (LC_ALL, lang[i]) == NULL)
72 	setlocale (LC_ALL, "C");
73 
74       bindtextdomain ("tstlang", ".");
75 
76       for (j = 0; j < data_cnt; ++j)
77 	printf ("%s - %s\n", strings[j].selection,
78 		gettext (strings[j].description));
79     }
80 
81   return 0;
82 }
83