/*
- * "$Id: language.c 6407 2007-03-27 17:45:12Z mike $"
+ * "$Id: language.c 6489 2007-04-30 17:55:15Z mike $"
*
* I18N/language support for the Common UNIX Printing System (CUPS).
*
*/
# ifdef HAVE_CF_LOCALE_ID
+
+typedef struct
+{
+ const char * const name; /* Language name */
+ const char * const locale; /* Locale name */
+} _apple_name_locale_t;
+
+static const _apple_name_locale_t apple_name_locale[] =
+{
+ { "en" , "en_US" },
+ { "no" , "nb" },
+ { "zh-Hans" , "zh_CN" },
+ { "zh-Hant" , "zh_TW" }
+};
+
/*
* 'appleLangDefault()' - Get the default locale string.
*/
static const char * /* O - Locale string */
appleLangDefault(void)
{
+ int i; /* Looping var */
CFPropertyListRef localizationList;
/* List of localization data */
CFStringRef languageName; /* Current name */
kCFStringEncodingASCII);
CFRelease(localeName);
- if (!strcmp(cg->language, "en"))
- strlcpy(cg->language, "en_US.UTF-8", sizeof(cg->language));
- else if (strchr(cg->language, '.') == NULL)
+ /*
+ * Map new language identifiers to locales...
+ */
+
+ for (i = 0;
+ i < sizeof(apple_name_locale) / sizeof(apple_name_locale[0]);
+ i++)
+ {
+ if (!strcmp(cg->language, apple_name_locale[i].name))
+ {
+ strlcpy(cg->language, apple_name_locale[i].locale,
+ sizeof(cg->language));
+ break;
+ }
+ }
+
+ /*
+ * Convert language subtag into region subtag...
+ */
+
+ if (cg->language[2] == '-')
+ cg->language[2] = '_';
+
+ if (strchr(cg->language, '.') == NULL)
strlcat(cg->language, ".UTF-8", sizeof(cg->language));
}
}
/*
- * End of "$Id: language.c 6407 2007-03-27 17:45:12Z mike $".
+ * End of "$Id: language.c 6489 2007-04-30 17:55:15Z mike $".
*/