From 49ab350c8a253def658f1ac0effc4e53c26ad7d9 Mon Sep 17 00:00:00 2001 From: Yoshito Umaoka Date: Fri, 11 May 2012 21:57:11 +0000 Subject: [PATCH] ICU-9265 Synchronized forLanguageTag test cases with ICU4C trunk. Also fixed a bug for u extension typeless keyword mapping (use 'yes' in ICU instead of 'true'). X-SVN-Rev: 31817 --- .../classes/core/src/com/ibm/icu/util/ULocale.java | 6 +++--- .../com/ibm/icu/dev/test/util/LocaleBuilderTest.java | 9 +++++++-- .../src/com/ibm/icu/dev/test/util/ULocaleTest.java | 11 ++++++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java b/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java index 534b0067e9b..f9346fcc904 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java @@ -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) { diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleBuilderTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleBuilderTest.java index 59c97b45b02..402ff13ec94 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleBuilderTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleBuilderTest.java @@ -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"}, diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java index ef8ceb42c08..72d5519a7b1 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java @@ -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++) { -- 2.40.0