/* 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 CAFE_DESKTOP_USE_UNSTABLE_API
#include "cafe-languages.h"
void test_one_locale(const gchar *locale);
void test_locales(void);
void test_one_locale(const gchar *locale)<--- The function 'test_one_locale' should have static linkage since it is not used outside of its translation unit.
{
char *lang, *country, *norm_locale;
char *language_code, *country_code, *codeset, *modifier;
lang = cafe_get_language_from_locale (locale, locale);
country = cafe_get_country_from_locale (locale, locale);
norm_locale = cafe_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 (cafe_parse_locale (locale, &language_code, &country_code, &codeset, &modifier)) {
lang = cafe_get_language_from_code (language_code, locale);
country = cafe_get_country_from_code (country_code, locale);
if (cafe_language_has_translations(language_code)) {
printf("[cafe_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("[cafe_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)<--- The function 'test_locales' should have static linkage since it is not used outside of its translation unit.
{
char **all;
guint i, len;
all= cafe_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;
}