1/* Test of the gettext functions.
2 Copyright (C) 2000-2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19
20#include <locale.h>
21#include <libintl.h>
22#include <stdlib.h>
23#include <stdio.h>
24
25#define N_(msgid) msgid
26
27struct data_t
28{
29 const char *selection;
30 const char *description;
31};
32
33int data_cnt = 2;
34struct data_t strings[] =
35{
36 { "String1", N_("First string for testing.") },
37 { "String2", N_("Another string for testing.") }
38};
39
40const int lang_cnt = 3;
41const char *lang[] = {"lang1", "lang2", "lang3"};
42
43static int
44do_test (void)
45{
46 int i;
47
48 /* Clean up environment. */
49 unsetenv (name: "LANGUAGE");
50 unsetenv (name: "LC_ALL");
51 unsetenv (name: "LC_MESSAGES");
52 unsetenv (name: "LC_CTYPE");
53 unsetenv (name: "LANG");
54 unsetenv (name: "OUTPUT_CHARSET");
55
56 textdomain (domainname: "tstlang");
57
58 for (i = 0; i < lang_cnt; ++i)
59 {
60 int j;
61
62 if (setlocale (LC_ALL, lang[i]) == NULL)
63 setlocale (LC_ALL, "C");
64 bindtextdomain ("tstlang", OBJPFX "domaindir");
65
66 for (j = 0; j < data_cnt; ++j)
67 printf (format: "%s - %s\n", strings[j].selection,
68 gettext (strings[j].description));
69 }
70
71 return 0;
72}
73
74#define TEST_FUNCTION do_test ()
75#include "../test-skeleton.c"
76

source code of glibc/intl/tst-gettext2.c