1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/* vi: set sw=4 ts=4 wrap ai: */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* */
#include <stdio.h>
#include <locale.h>
#define MATE_DESKTOP_USE_UNSTABLE_API
#include "mate-languages.h"
void test_one_locale(const gchar *locale);
void test_locales(void);
void test_one_locale(const gchar *locale)
{
char *lang, *country, *norm_locale;
char *language_code, *country_code, *codeset, *modifier;
lang = mate_get_language_from_locale (locale, locale);
country = mate_get_country_from_locale (locale, locale);
norm_locale = mate_normalize_locale (locale);
printf("Current locale: %s\n", locale);
printf("[locale]:\t\tlang=%s, country=%s, locale=%s\n", lang, country, norm_locale);
g_free(lang);
g_free(country);
g_free(norm_locale);
if (mate_parse_locale (locale, &language_code, &country_code, &codeset, &modifier)) {
lang = mate_get_language_from_code (language_code, locale);
country = mate_get_country_from_code (country_code, locale);
if (mate_language_has_translations(language_code)) {
printf("[mate_parse_locale]:\tlang_code=%s, country_code=%s, code=%s, modifier=%s\n"
"[code]:\t\t\tlang=%s, country=%s, Has translation\n",
language_code, country_code, codeset, modifier,
lang, country);
} else {
printf("[mate_parse_locale]:\tlang_code=%s, country_code=%s, code=%s, modifier=%s\n"
"[code]:\t\t\tlang=%s, country=%s\n",
language_code, country_code, codeset, modifier,
lang, country);
}
g_free(lang);
g_free(country);
}
putchar('\n');
g_free(language_code);
g_free(country_code);
g_free(codeset);
g_free(modifier);
}
void test_locales(void)
{
char **all;
guint i, len;
all= mate_get_all_locales ();
len = g_strv_length (all);
for (i =0; i < len; i++) {
test_one_locale(all[i]);
}
g_strfreev(all);
}
int main(int argc, char **argv)
{
if (argc == 2) {
test_one_locale(argv[1]);
} else {
test_locales();
}
return 0;
}
|