]> granicus.if.org Git - icu/commitdiff
ICU-10244 (C) LocaleData.getLocaleSeparator now returns piece between {0} and {1...
authorPeter Edberg <pedberg@unicode.org>
Thu, 11 Jul 2013 18:59:13 +0000 (18:59 +0000)
committerPeter Edberg <pedberg@unicode.org>
Thu, 11 Jul 2013 18:59:13 +0000 (18:59 +0000)
X-SVN-Rev: 33913

icu4j/main/classes/core/src/com/ibm/icu/util/LocaleData.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleDataTest.java

index 92f29c346b4591f5b833004afbeee8b230f27da8..5628f9c514ae904cbffb2dba5aa8db448e7e8e03 100644 (file)
@@ -387,8 +387,15 @@ public final class LocaleData {
      * @stable ICU 4.2
      */ 
     public String getLocaleSeparator() {
+      String sub0 = "{0}";
+      String sub1 = "{1}";
       ICUResourceBundle locDispBundle = (ICUResourceBundle) langBundle.get(LOCALE_DISPLAY_PATTERN);
       String  localeSeparator = locDispBundle.getStringWithFallback(SEPARATOR);
+      int index0 = localeSeparator.indexOf(sub0);
+      int index1 = localeSeparator.indexOf(sub1);
+      if (index0 >= 0 && index1 >= 0 && index0 <= index1) {
+          return localeSeparator.substring(index0 + sub0.length(), index1);
+      }
       return localeSeparator;
     }
     
index c8efa7389ad3814283a15587448a14a397bb2c8d..976d13c7c1ffa5a4376d3ed389204187a7b3789e 100644 (file)
@@ -367,11 +367,34 @@ public class LocaleDataTest extends TestFmwk{
     }
 
     public void TestLocaleDisplayPattern(){
-        LocaleData ld = LocaleData.getInstance();
-        logln("Default locale "+ " LocaleDisplayPattern:" + ld.getLocaleDisplayPattern());
-        logln("Default locale "+ " LocaleSeparator:" + ld.getLocaleSeparator());
+        ULocale locale = ULocale.ENGLISH;
+        LocaleData ld = LocaleData.getInstance(locale);
+        String pattern = ld.getLocaleDisplayPattern();
+        String separator = ld.getLocaleSeparator();
+        logln("LocaleDisplayPattern for locale " + locale + ": " + pattern);
+        if (!pattern.equals("{0} ({1})")) {
+          errln("Unexpected LocaleDisplayPattern for locale: "+ locale);
+        }
+        logln("LocaleSeparator for locale " + locale + ": " + separator);
+        if (!separator.equals(", ")) {
+          errln("Unexpected LocaleSeparator for locale: "+ locale);
+        }
+
+        locale = ULocale.CHINESE;
+        ld = LocaleData.getInstance(locale);
+        pattern = ld.getLocaleDisplayPattern();
+        separator = ld.getLocaleSeparator();
+        logln("LocaleDisplayPattern for locale " + locale + ": " + pattern);
+        if (!pattern.equals("{0}\uFF08{1}\uFF09")) {
+          errln("Unexpected LocaleDisplayPattern for locale: "+ locale);
+        }
+        logln("LocaleSeparator for locale " + locale + ": " + separator);
+        if (!separator.equals("\u3001")) {
+          errln("Unexpected LocaleSeparator for locale: "+ locale);
+        }
+
         for(int i = 0; i < availableLocales.length; i++){
-          ULocale locale = availableLocales[i];
+          locale = availableLocales[i];
           ld = LocaleData.getInstance(locale);
           logln(locale.toString() + " LocaleDisplayPattern:" + ld.getLocaleDisplayPattern());
           logln(locale.toString() + " LocaleSeparator:" + ld.getLocaleSeparator());