]> granicus.if.org Git - icu/commitdiff
ICU-9265 Synchronized forLanguageTag test cases with ICU4C trunk. Also fixed a bug...
authorYoshito Umaoka <y.umaoka@gmail.com>
Fri, 11 May 2012 21:57:11 +0000 (21:57 +0000)
committerYoshito Umaoka <y.umaoka@gmail.com>
Fri, 11 May 2012 21:57:11 +0000 (21:57 +0000)
X-SVN-Rev: 31817

icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleBuilderTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java

index 534b0067e9be0e6603754a5eeda66477b56fff46..f9346fcc9045987c7e9830e82601331cb6fb303c 100644 (file)
@@ -3502,7 +3502,7 @@ public final class ULocale implements Serializable {
                         String bcpType = uext.getUnicodeLocaleType(bcpKey);
                         // convert to legacy key/type
                         String lkey = bcp47ToLDMLKey(bcpKey);
-                        String ltype = bcp47ToLDMLType(lkey, ((bcpType.length() == 0) ? "true" : bcpType)); // use "true" as the value of typeless keywords
+                        String ltype = bcp47ToLDMLType(lkey, ((bcpType.length() == 0) ? "yes" : bcpType)); // use "yes" as the value of typeless keywords
                         // special handling for u-va-posix, since this is a variant, not a keyword
                         if (lkey.equals("va") && ltype.equals("posix") && base.getVariant().length() == 0) {
                             id = id + "_POSIX";
@@ -3956,8 +3956,8 @@ public final class ULocale implements Serializable {
                     if (kwKey.length() != 1) {
                         // Unicode locale key
                         kwKey = bcp47ToLDMLKey(kwKey);
-                        // use "true" as the value of typeless keywords
-                        kwVal = bcp47ToLDMLType(kwKey, ((kwVal.length() == 0) ? "true" : kwVal));
+                        // use "yes" as the value of typeless keywords
+                        kwVal = bcp47ToLDMLType(kwKey, ((kwVal.length() == 0) ? "yes" : kwVal));
                     }
 
                     if (addSep) {
index 59c97b45b02678477816c3e606e7b2a311ea5f4a..402ff13ec9439bf6d2d97c0de87bc1b4818b0792 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *******************************************************************************
- * Copyright (C) 2009-2010, International Business Machines Corporation and    *
+ * Copyright (C) 2009-2012, International Business Machines Corporation and    *
  * others. All Rights Reserved.                                                *
  *******************************************************************************
  */
@@ -79,7 +79,12 @@ public class LocaleBuilderTest extends TestFmwk {
                 {"E", "z", "ExtZ", "L", "en", "E", "z", null, "T", "en", "en"},
                 {"E", "a", "x", "X"},
                 {"E", "a", "abc_def", "T", "und-a-abc-def", "@a=abc-def"},
-                {"L", "en", "E", "u", "bbb-aaa-00", "T", "en-u-aaa-bbb-00-true", "en@00=true;attribute=aaa-bbb"},
+                // Design limitation - typeless u extension keyword 00 below is interpreted as a boolean value true/yes.
+                // With the legacy keyword syntax, "yes" is used for such boolean value instead of "true".
+                // However, once the legacy keyword is translated back to BCP 47 u extension, key "00" is unknown,
+                // so "yes" is preserved - not mapped to "true". We could change the code to automatically transform
+                // "yes" to "true", but it will break roundtrip conversion if BCP 47 u extension has "00-yes".
+                {"L", "en", "E", "u", "bbb-aaa-00", "T", "en-u-aaa-bbb-00-yes", "en@00=yes;attribute=aaa-bbb"},
                 {"L", "fr", "R", "FR", "P", "Yoshito-ICU", "T", "fr-FR-x-yoshito-icu", "fr_FR@x=yoshito-icu"},
                 {"L", "ja", "R", "jp", "K", "ca", "japanese", "T", "ja-JP-u-ca-japanese", "ja_JP@calendar=japanese"},
                 {"K", "co", "PHONEBK", "K", "ca", "gregory", "L", "De", "T", "de-u-ca-gregory-co-phonebk", "de@calendar=gregorian;collation=phonebook"},
index ef8ceb42c08daf9886ce1ff9c94dc387a8f773ed..72d5519a7b132342c224b36051fb30d92f33c3e5 100644 (file)
@@ -3869,13 +3869,22 @@ public class ULocaleTest extends TestFmwk {
             {"ar-x-1-2-3",          "ar@x=1-2-3",           NOERROR},
             {"fr-u-nu-latn-cu-eur", "fr@currency=eur;numbers=latn", NOERROR},
             {"de-k-kext-u-co-phonebk-nu-latn",  "de@collation=phonebook;k=kext;numbers=latn",   NOERROR},
-            {"ja-u-cu-jpy-ca-jp",   "ja@calendar=true;currency=jpy;jp=true",  NOERROR},
+            {"ja-u-cu-jpy-ca-jp",   "ja@calendar=yes;currency=jpy;jp=yes",  NOERROR},
             {"en-us-u-tz-usnyc",    "en_US@timezone=America/New_York",      NOERROR},
             {"und-a-abc-def",       "@a=abc-def",           NOERROR},
             {"zh-u-ca-chinese-x-u-ca-chinese",  "zh@calendar=chinese;x=u-ca-chinese",   NOERROR},
             {"fr--FR",              "fr",                   Integer.valueOf(3)},
             {"fr-",                 "fr",                   Integer.valueOf(3)},
             {"x-elmer",             "@x=elmer",             NOERROR},
+            {"en-US-u-attr1-attr2-ca-gregory", "en_US@attribute=attr1-attr2;calendar=gregorian",    NOERROR},
+            {"sr-u-kn",             "sr@colnumeric=yes",    NOERROR},
+            {"de-u-kn-co-phonebk",  "de@collation=phonebook;colnumeric=yes",    NOERROR},
+            {"en-u-attr2-attr1-kn-kb",  "en@attribute=attr1-attr2;colbackwards=yes;colnumeric=yes", NOERROR},
+            {"ja-u-ijkl-efgh-abcd-ca-japanese-xx-yyy-zzz-kn",   "ja@attribute=abcd-efgh-ijkl;calendar=japanese;colnumeric=yes;xx=yyy-zzz",  NOERROR},
+
+            {"de-u-xc-xphonebk-co-phonebk-ca-buddhist-mo-very-lo-extensi-xd-that-de-should-vc-probably-xz-killthebuffer",
+             "de@calendar=buddhist;collation=phonebook;de=should;lo=extensi;mo=very;vc=probably;xc=xphonebk;xd=that;xz=yes", Integer.valueOf(92)},
+
         };
 
         for (int i = 0; i < langtag_to_locale.length; i++) {