From 18223f50830accdf85504630723c196e1628737a Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Tue, 12 Feb 2002 18:42:47 +0000 Subject: [PATCH] ICU-1616 Fix some more of the Locale differences between countries. X-SVN-Rev: 7629 --- icu4c/source/data/locales/en_CA.txt | 8 +- icu4c/source/data/locales/es_US.txt | 4 + icu4c/source/data/locales/fr.txt | 13 -- icu4c/source/data/locales/fr_CA.txt | 4 +- icu4c/source/data/locales/fr_FR.txt | 13 ++ icu4c/source/data/locales/fr_LU.txt | 13 ++ icu4c/source/data/locales/fr_MC.txt | 13 ++ icu4c/source/data/locales/uk.txt | 4 + icu4c/source/data/locales/uk_UA.txt | 2 +- icu4c/source/test/cintltst/cloctst.c | 189 ++++++++++++++++++++++++++- icu4c/source/test/cintltst/cloctst.h | 4 + 11 files changed, 247 insertions(+), 20 deletions(-) diff --git a/icu4c/source/data/locales/en_CA.txt b/icu4c/source/data/locales/en_CA.txt index 3dc98df5a73..860f6ebcb40 100644 --- a/icu4c/source/data/locales/en_CA.txt +++ b/icu4c/source/data/locales/en_CA.txt @@ -16,7 +16,7 @@ en_CA { // AU { "Australia" } // NZ { "New Zealand" } // } - CurrencyElements { + CurrencyElements { "$", "CAD", ".", @@ -32,6 +32,12 @@ en_CA { "dd/MM/yy", "{1} {0}", } + NumberPatterns { + "#,##0.###;-#,##0.###", + "\u00A4#,##0.00;(\u00A4#,##0.00)", + "#,##0%", + "#E0", + } // Duplicated in parent // Languages { // en { "English" } diff --git a/icu4c/source/data/locales/es_US.txt b/icu4c/source/data/locales/es_US.txt index c4646d063d3..855bacb0ffc 100644 --- a/icu4c/source/data/locales/es_US.txt +++ b/icu4c/source/data/locales/es_US.txt @@ -25,6 +25,10 @@ es_US { // "\u221e", // "\ufffd", // } + DateTimeElements:intvector { + 1, + 1, + } DateTimePatterns { "h:mm:ss a z", "h:mm:ss a z", diff --git a/icu4c/source/data/locales/fr.txt b/icu4c/source/data/locales/fr.txt index 16d341d17a1..a76afdc1b56 100644 --- a/icu4c/source/data/locales/fr.txt +++ b/icu4c/source/data/locales/fr.txt @@ -353,19 +353,6 @@ fr { "novembre", "d\u00E9cembre", } - NumberElements { - ",", - "\u00A0", //   - ";", - "%", - "0", - "#", - "-", - "E", - "\u2030", - "\u221E", - "\uFFFD", - } NumberPatterns { "#,##0.###;-#,##0.###", "#,##0.00 \u00A4;-#,##0.00 \u00A4", diff --git a/icu4c/source/data/locales/fr_CA.txt b/icu4c/source/data/locales/fr_CA.txt index f34a28a3471..e7abf3a77fc 100644 --- a/icu4c/source/data/locales/fr_CA.txt +++ b/icu4c/source/data/locales/fr_CA.txt @@ -10,7 +10,7 @@ fr_CA { CurrencyElements { "$", "CAD", - ",", + ".", } DateTimePatterns { "HH' h 'mm' min 'ss' s 'z", @@ -27,7 +27,7 @@ fr_CA { // LocaleString { "fr_CA" } NumberPatterns { "#,##0.###;-#,##0.###", - "#,##0.00 \u00A4;(#,##0.00\u00A4)", + "\u00A4#,##0.00;(\u00A4#,##0.00)", "#,##0%", "#E0", } diff --git a/icu4c/source/data/locales/fr_FR.txt b/icu4c/source/data/locales/fr_FR.txt index f2199a5ccc1..9e26e4048da 100644 --- a/icu4c/source/data/locales/fr_FR.txt +++ b/icu4c/source/data/locales/fr_FR.txt @@ -16,6 +16,19 @@ fr_FR { 2, 1, } + NumberElements { + ",", + "\u00A0", //   + ";", + "%", + "0", + "#", + "-", + "E", + "\u2030", + "\u221E", + "\uFFFD", + } // LocaleString { "fr_FR" } // ShortCountry { "FRA" } LocaleID:int { 0x040c } diff --git a/icu4c/source/data/locales/fr_LU.txt b/icu4c/source/data/locales/fr_LU.txt index 2de17f75a03..83481e990ef 100644 --- a/icu4c/source/data/locales/fr_LU.txt +++ b/icu4c/source/data/locales/fr_LU.txt @@ -16,6 +16,19 @@ fr_LU { 2, 1, } + NumberElements { + ",", + ".", + ";", + "%", + "0", + "#", + "-", + "E", + "\u2030", + "\u221E", + "\uFFFD", + } // LocaleString { "fr_LU" } // ShortCountry { "LUX" } LocaleID:int { 0x140c } diff --git a/icu4c/source/data/locales/fr_MC.txt b/icu4c/source/data/locales/fr_MC.txt index a7224d09540..45f1283b52a 100644 --- a/icu4c/source/data/locales/fr_MC.txt +++ b/icu4c/source/data/locales/fr_MC.txt @@ -17,4 +17,17 @@ fr_MC{ 2, 1, } + NumberElements { + ",", + "\u00A0", //   + ";", + "%", + "0", + "#", + "-", + "E", + "\u2030", + "\u221E", + "\uFFFD", + } } \ No newline at end of file diff --git a/icu4c/source/data/locales/uk.txt b/icu4c/source/data/locales/uk.txt index 30542570425..d99ded1a944 100644 --- a/icu4c/source/data/locales/uk.txt +++ b/icu4c/source/data/locales/uk.txt @@ -47,6 +47,10 @@ uk { Countries { UA { "\u0423\u043A\u0440\u0430\u0457\u043D\u0430" } } + DateTimeElements:intvector { + 2, + 1, + } DateTimePatterns { "HH:mm:ss z", "HH:mm:ss z", diff --git a/icu4c/source/data/locales/uk_UA.txt b/icu4c/source/data/locales/uk_UA.txt index f7d3e8285ef..5f0bc0d91c0 100644 --- a/icu4c/source/data/locales/uk_UA.txt +++ b/icu4c/source/data/locales/uk_UA.txt @@ -15,7 +15,7 @@ uk_UA { // LocaleString { "uk_UA" } NumberPatterns { "#,##0.###;-#,##0.###", - "#,##0.## \u00A4;-#,##0.## \u00A4", + "#,##0.00 \u00A4;-#,##0.00 \u00A4", "#,##0%", "#E0", } diff --git a/icu4c/source/test/cintltst/cloctst.c b/icu4c/source/test/cintltst/cloctst.c index 738bd957383..b53d9e0f28d 100644 --- a/icu4c/source/test/cintltst/cloctst.c +++ b/icu4c/source/test/cintltst/cloctst.c @@ -143,6 +143,7 @@ void addLocaleTest(TestNode** root) addTest(root, &TestSimpleDisplayNames, "tsutil/cloctst/TestSimpleDisplayNames"); addTest(root, &TestVariantParsing, "tsutil/cloctst/TestVariantParsing"); addTest(root, &TestLocaleStructure, "tsutil/cloctst/TestLocaleStructure"); + addTest(root, &TestConsistentCountryInfo,"tsutil/cloctst/TestConsistentCountryInfo"); } @@ -1303,7 +1304,10 @@ TestKeyInRootRecursive(UResourceBundle *root, UResourceBundle *currentBundle, co locale); } } - if (sameArray) { + /* Special exception es_US and DateTimeElements */ + if (sameArray + && !(strcmp(locale, "es_US") == 0 && strcmp(subBundleKey, "DateTimeElements") == 0)) + { log_err("Arrays are the same with key \"%s\" in \"%s\" from root for locale \"%s\"\n", subBundleKey, ures_getKey(currentBundle), @@ -1360,12 +1364,14 @@ TestKeyInRootRecursive(UResourceBundle *root, UResourceBundle *currentBundle, co ures_getSize(subBundle)); } - for (idx = 0; idx < minSize && sameArray; idx++) { + for (idx = 0; idx < minSize; idx++) { int32_t rootStrLen, localeStrLen; const UChar *rootStr = ures_getStringByIndex(subRootBundle,idx,&rootStrLen,&errorCode); const UChar *localeStr = ures_getStringByIndex(subBundle,idx,&localeStrLen,&errorCode); if (rootStr && localeStr && U_SUCCESS(errorCode)) { - sameArray = (u_strcmp(rootStr, localeStr) == 0); + if (u_strcmp(rootStr, localeStr) != 0) { + sameArray = FALSE; + } } else { log_err("Got a NULL string with key \"%s\" in \"%s\" at index %d for root or locale \"%s\"\n", @@ -1657,3 +1663,180 @@ TestLocaleStructure(void) { ures_close(currentLocale); } } + +static void +compareArrays(const char *keyName, + UResourceBundle *fromArray, const char *fromLocale, + UResourceBundle *toArray, const char *toLocale, + int32_t start, int32_t end) +{ + int32_t fromSize = ures_getSize(fromArray); + int32_t toSize = ures_getSize(fromArray); + int32_t idx; + UErrorCode errorCode = U_ZERO_ERROR; + + if (fromSize > toSize) { + fromSize = toSize; + log_err("Arrays are different size from \"%s\" to \"%s\"\n", + fromLocale, + toLocale); + } + + for (idx = start; idx <= end; idx++) { + const UChar *fromBundleStr = ures_getStringByIndex(fromArray, idx, NULL, &errorCode); + const UChar *toBundleStr = ures_getStringByIndex(toArray, idx, NULL, &errorCode); + if (u_strcmp(fromBundleStr, toBundleStr) != 0) { + log_err("Difference for %s at index %d from %s= \"%s\" to %s= \"%s\"\n", + keyName, + idx, + fromLocale, + austrdup(fromBundleStr), + toLocale, + austrdup(toBundleStr)); + } + } +} + +static void +compareConsistentCountryInfo(const char *fromLocale, const char *toLocale) { + UErrorCode errorCode = U_ZERO_ERROR; + UResourceBundle *fromDateTimeElements, *toDateTimeElements; + UResourceBundle *fromArray, *toArray; + UResourceBundle *fromLocaleBund = ures_open(NULL, fromLocale, &errorCode); + UResourceBundle *toLocaleBund = ures_open(NULL, toLocale, &errorCode); + + if(U_FAILURE(errorCode)) { + log_err("Can't open resource bundle %s or %s\n", fromLocale, toLocale); + return; + } + + fromDateTimeElements = ures_getByKey(fromLocaleBund, "DateTimeElements", NULL, &errorCode); + toDateTimeElements = ures_getByKey(toLocaleBund, "DateTimeElements", NULL, &errorCode); + if (strcmp(fromLocale, "ar_IN") != 0) + { + int32_t fromSize; + int32_t toSize; + int32_t idx; + UBool sameArray = TRUE; + const int32_t *fromBundleArr = ures_getIntVector(fromDateTimeElements, &fromSize, &errorCode); + const int32_t *toBundleArr = ures_getIntVector(toDateTimeElements, &toSize, &errorCode); + + if (fromSize > toSize) { + fromSize = toSize; + log_err("Arrays are different size with key \"DateTimeElements\" from \"%s\" to \"%s\"\n", + fromLocale, + toLocale); + } + + for (idx = 0; idx < fromSize; idx++) { + if (fromBundleArr[idx] != toBundleArr[idx]) { + log_err("Difference with key \"DateTimeElements\" at index %d from \"%s\" to \"%s\"\n", + idx, + fromLocale, + toLocale); + } + } + } + ures_close(fromDateTimeElements); + ures_close(toDateTimeElements); + + fromArray = ures_getByKey(fromLocaleBund, "CurrencyElements", NULL, &errorCode); + toArray = ures_getByKey(toLocaleBund, "CurrencyElements", NULL, &errorCode); + { + /* The first one is probably localized. */ + compareArrays("CurrencyElements", fromArray, fromLocale, toArray, toLocale, 1, 2); + } + ures_close(fromArray); + ures_close(toArray); + + fromArray = ures_getByKey(fromLocaleBund, "NumberPatterns", NULL, &errorCode); + toArray = ures_getByKey(toLocaleBund, "NumberPatterns", NULL, &errorCode); + { + compareArrays("NumberPatterns", fromArray, fromLocale, toArray, toLocale, 0, 3); + } + ures_close(fromArray); + ures_close(toArray); + + /* Difficult to test properly */ +/* + fromArray = ures_getByKey(fromLocaleBund, "DateTimePatterns", NULL, &errorCode); + toArray = ures_getByKey(toLocaleBund, "DateTimePatterns", NULL, &errorCode); + { + compareArrays("DateTimePatterns", fromArray, fromLocale, toArray, toLocale); + } + ures_close(fromArray); + ures_close(toArray);*/ + + fromArray = ures_getByKey(fromLocaleBund, "NumberElements", NULL, &errorCode); + toArray = ures_getByKey(toLocaleBund, "NumberElements", NULL, &errorCode); + { + compareArrays("NumberElements", fromArray, fromLocale, toArray, toLocale, 0, 3); + /* Index 4 is a script based 0 */ + compareArrays("NumberElements", fromArray, fromLocale, toArray, toLocale, 5, 10); + } + ures_close(fromArray); + ures_close(toArray); + + ures_close(fromLocaleBund); + ures_close(toLocaleBund); +} + +static void +TestConsistentCountryInfo(void) { +/* UResourceBundle *fromLocale, *toLocale;*/ + int32_t locCount = uloc_countAvailable(); + int32_t fromLocIndex, toLocIndex; + + int32_t fromCountryLen, toCountryLen; + char fromCountry[ULOC_FULLNAME_CAPACITY], toCountry[ULOC_FULLNAME_CAPACITY]; + + int32_t fromVariantLen, toVariantLen; + char fromVariant[ULOC_FULLNAME_CAPACITY], toVariant[ULOC_FULLNAME_CAPACITY]; + + UErrorCode errorCode = U_ZERO_ERROR; + + for (fromLocIndex = 0; fromLocIndex < locCount; fromLocIndex++) { + const char *fromLocale = uloc_getAvailable(fromLocIndex); + + errorCode=U_ZERO_ERROR; + fromCountryLen = uloc_getCountry(fromLocale, fromCountry, ULOC_FULLNAME_CAPACITY, &errorCode); + if (fromCountryLen <= 0) { + /* Ignore countryless locales */ + continue; + } + fromVariantLen = uloc_getVariant(fromLocale, fromVariant, ULOC_FULLNAME_CAPACITY, &errorCode); + if (fromVariantLen > 0) { + /* Most variants are ignorable like PREEURO, or collation variants. */ + continue; + } + /* Start comparing only after the current index. + Previous loop should have already compared fromLocIndex. + */ + for (toLocIndex = fromLocIndex + 1; toLocIndex < locCount; toLocIndex++) { + const char *toLocale = uloc_getAvailable(toLocIndex); + + toCountryLen = uloc_getCountry(toLocale, toCountry, ULOC_FULLNAME_CAPACITY, &errorCode); + if(U_FAILURE(errorCode)) { + log_err("Unknown failure fromLocale=%s toLocale=%s errorCode=%s\n", + fromLocale, toLocale, u_errorName(errorCode)); + continue; + } + + if (toCountryLen <= 0) { + /* Ignore countryless locales */ + continue; + } + toVariantLen = uloc_getVariant(toLocale, toVariant, ULOC_FULLNAME_CAPACITY, &errorCode); + if (toVariantLen > 0) { + /* Most variants are ignorable like PREEURO, or collation variants. */ + /* They're a variant for a reason. */ + continue; + } + if (strcmp(fromCountry, toCountry) == 0) { + log_verbose("comparing fromLocale=%s toLocale=%s\n", + fromLocale, toLocale); + compareConsistentCountryInfo(fromLocale, toLocale); + } + } + } +} diff --git a/icu4c/source/test/cintltst/cloctst.h b/icu4c/source/test/cintltst/cloctst.h index 0f566b3ad76..510047b8e8d 100644 --- a/icu4c/source/test/cintltst/cloctst.h +++ b/icu4c/source/test/cintltst/cloctst.h @@ -61,8 +61,12 @@ static void TestDisplayNames(void); **/ static void TestVariantParsing(void); + /* Make sure that the locale data is good. */ static void TestLocaleStructure(void); + /* Make sure that Country information is the same across locales, within reason. */ + static void TestConsistentCountryInfo(void); + /** * routine to perform subtests, used by TestDisplayNames */