From: msweet Date: Mon, 10 Aug 2015 17:07:30 +0000 (+0000) Subject: Additional fixes for Hong Kong locale () X-Git-Tag: v2.2b1~209 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3647435025e7db95f6239edf21e377566b23be64;p=thirdparty%2Fcups.git Additional fixes for Hong Kong locale () git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@12841 a1ca3aef-8c08-0410-bb20-df032aa958be --- diff --git a/cups/language.c b/cups/language.c index 00c7400545..69e391f2a8 100644 --- a/cups/language.c +++ b/cups/language.c @@ -1180,7 +1180,7 @@ appleLangDefault(void) * See if we have an Info.plist file in the bundle... */ - CFStringGetCString(cfpath, path,sizeof(path), kCFStringEncodingUTF8); + CFStringGetCString(cfpath, path, sizeof(path), kCFStringEncodingUTF8); DEBUG_printf(("3appleLangDefault: Got a resource URL (\"%s\")", path)); strlcat(path, "Contents/Info.plist", sizeof(path)); @@ -1211,7 +1211,6 @@ appleLangDefault(void) if (localizationList) { - #ifdef DEBUG if (CFGetTypeID(localizationList) == CFArrayGetTypeID()) DEBUG_printf(("3appleLangDefault: Got localizationList, %d entries.", @@ -1287,6 +1286,8 @@ appleLangDefault(void) strlcpy(cg->language, "en_US.UTF-8", sizeof(cg->language)); } } + else + DEBUG_printf(("3appleLangDefault: Using previous locale \"%s\".", cg->language)); /* * Return the cached locale... diff --git a/cups/ppd.c b/cups/ppd.c index d1f9cadf96..504e269326 100644 --- a/cups/ppd.c +++ b/cups/ppd.c @@ -3,7 +3,7 @@ * * PPD file routines for CUPS. * - * Copyright 2007-2014 by Apple Inc. + * Copyright 2007-2015 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -418,10 +418,10 @@ _ppdOpen( char custom_name[PPD_MAX_NAME]; /* CustomFoo attribute name */ ppd_attr_t *custom_attr; /* CustomFoo attribute */ - char ll[4], /* Language + '.' */ - ll_CC[7]; /* Language + country + '.' */ - size_t ll_len = 0, /* Language length */ - ll_CC_len = 0; /* Language + country length */ + char ll[7], /* Base language + '.' */ + ll_CC[7]; /* Language w/country + '.' */ + size_t ll_len = 0, /* Base language length */ + ll_CC_len = 0; /* Language w/country length */ static const char * const ui_keywords[] = { #ifdef CUPS_USE_FULL_UI_KEYWORDS_LIST @@ -519,7 +519,17 @@ _ppdOpen( return (NULL); snprintf(ll_CC, sizeof(ll_CC), "%s.", lang->language); - snprintf(ll, sizeof(ll), "%2.2s.", lang->language); + + /* + * + * + * Need to use a different base language for some locales... + */ + + if (!strcmp(lang->language, "zh_HK")) + strlcpy(ll, "zh_TW.", sizeof(ll)); + else + snprintf(ll, sizeof(ll), "%2.2s.", lang->language); ll_CC_len = strlen(ll_CC); ll_len = strlen(ll); diff --git a/cups/testlang.c b/cups/testlang.c index 701c14db40..b00505da4e 100644 --- a/cups/testlang.c +++ b/cups/testlang.c @@ -3,7 +3,7 @@ * * Localization test program for CUPS. * - * Copyright 2007-2010 by Apple Inc. + * Copyright 2007-2015 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -50,8 +50,6 @@ main(int argc, /* I - Number of command-line arguments */ }; - _cupsSetLocale(argv); - if (argc == 1) { language = cupsLangDefault(); @@ -61,8 +59,13 @@ main(int argc, /* I - Number of command-line arguments */ { language = cupsLangGet(argv[1]); language2 = cupsLangGet(argv[1]); + + setenv("LANG", argv[1], 1); + setenv("SOFTWARE", "CUPS/" CUPS_SVERSION, 1); } + _cupsSetLocale(argv); + if (language != language2) { errors ++; @@ -105,6 +108,45 @@ main(int argc, /* I - Number of command-line arguments */ } } + if (argc == 3) + { + ppd_file_t *ppd; /* PPD file */ + ppd_option_t *option; /* PageSize option */ + ppd_choice_t *choice; /* PageSize/Letter choice */ + + if ((ppd = ppdOpenFile(argv[2])) == NULL) + { + printf("Unable to open PPD file \"%s\".\n", argv[2]); + errors ++; + } + else + { + ppdLocalize(ppd); + + if ((option = ppdFindOption(ppd, "PageSize")) == NULL) + { + puts("No PageSize option."); + errors ++; + } + else + { + printf("PageSize: %s\n", option->text); + + if ((choice = ppdFindChoice(option, "Letter")) == NULL) + { + puts("No Letter PageSize choice."); + errors ++; + } + else + { + printf("Letter: %s\n", choice->text); + } + } + + ppdClose(ppd); + } + } + return (errors > 0); }