예제 #1
0
static char *
get_translated_territory (const char *code,
                          const char *locale)
{
        const char *territory;
        char       *name;

        territory = get_territory (code);

        name = NULL;
        if (territory != NULL) {
                const char *translated_territory;
                locale_t loc;
                locale_t old_locale;
                g_autofree char *tmp = NULL;

                if (locale != NULL) {
                        loc = newlocale (LC_MESSAGES_MASK, locale, (locale_t) 0);
                        if (loc == (locale_t) 0)
                                return NULL;
                        old_locale = uselocale (loc);
                }

                translated_territory = dgettext ("iso_3166", territory);
                tmp = get_first_item_in_semicolon_list (translated_territory);
                name = capitalize_utf8_string (tmp);

                if (locale != NULL) {
                        uselocale (old_locale);
                        freelocale (loc);
                }
        }

        return name;
}
예제 #2
0
static char *
get_display_name (const char *language)
{
  const char  *translated;
  char *tmp;
  char *name;

  translated = dgettext ("iso_639", language);

  tmp = get_first_item_in_semicolon_list (translated);
  name = capitalize_utf8_string (tmp);
  g_free (tmp);

  return name;
}
예제 #3
0
static char *
get_translated_language (const char *code,
                         const char *locale)
{
        const char *language;
        char *name;

        language = get_language (code);

        name = NULL;
        if (language != NULL) {
                const char *translated_name;
                locale_t loc;
                locale_t old_locale;

                if (locale != NULL) {
                        loc = newlocale (LC_MESSAGES_MASK, locale, (locale_t) 0);
                        if (loc == (locale_t) 0)
                                return NULL;
                        old_locale = uselocale (loc);
                }

                if (is_fallback_language (code)) {
                        name = g_strdup (_("Unspecified"));
                } else {
                        g_autofree char *tmp = NULL;
                        translated_name = dgettext ("iso_639", language);
                        tmp = get_first_item_in_semicolon_list (translated_name);
                        name = capitalize_utf8_string (tmp);
                }

                if (locale != NULL) {
                        uselocale (old_locale);
                        freelocale (loc);
                }
        }

        return name;
}