changeset 45461:8b6f0a3850ab

8178872: Decimal form is inconsistent between CLDR and Java in some special locales Reviewed-by: naoto
author rgoel
date Thu, 08 Jun 2017 12:15:54 +0530
parents 73ef931229ca
children 0de8011890c0 8360163ddb7f
files jdk/make/src/classes/build/tools/cldrconverter/LDMLParseHandler.java jdk/test/sun/text/resources/LocaleData.cldr jdk/test/sun/text/resources/LocaleDataTest.java
diffstat 3 files changed, 64 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/make/src/classes/build/tools/cldrconverter/LDMLParseHandler.java	Wed Jun 07 08:58:19 2017 -0700
+++ b/jdk/make/src/classes/build/tools/cldrconverter/LDMLParseHandler.java	Thu Jun 08 12:15:54 2017 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -549,12 +549,20 @@
         case "decimal":
             // for FormatData
             // copy string for later assembly into NumberElements
-            pushStringEntry(qName, attributes, currentNumberingSystem + "NumberElements/decimal");
+            if (currentContainer.getqName().equals("symbols")) {
+                pushStringEntry(qName, attributes, currentNumberingSystem + "NumberElements/decimal");
+            } else {
+                pushIgnoredContainer(qName);
+            }
             break;
         case "group":
             // for FormatData
             // copy string for later assembly into NumberElements
-            pushStringEntry(qName, attributes, currentNumberingSystem + "NumberElements/group");
+            if (currentContainer.getqName().equals("symbols")) {
+                pushStringEntry(qName, attributes, currentNumberingSystem + "NumberElements/group");
+            } else {
+                pushIgnoredContainer(qName);
+            }
             break;
         case "list":
             // for FormatData
--- a/jdk/test/sun/text/resources/LocaleData.cldr	Wed Jun 07 08:58:19 2017 -0700
+++ b/jdk/test/sun/text/resources/LocaleData.cldr	Thu Jun 08 12:15:54 2017 +0530
@@ -8274,3 +8274,29 @@
 
 # bug #8075173
 FormatData/de/standalone.MonthAbbreviations/2=M\u00e4r
+
+# bug #8178872
+FormatData/pt_PT/latn.NumberElements/0=,
+FormatData/pt_PT/latn.NumberElements/1=\u00a0
+FormatData/pt_AO/latn.NumberElements/0=,
+FormatData/pt_AO/latn.NumberElements/1=\u00a0
+FormatData/pt_CH/latn.NumberElements/0=,
+FormatData/pt_CH/latn.NumberElements/1=\u00a0
+FormatData/pt_CV/latn.NumberElements/0=,
+FormatData/pt_CV/latn.NumberElements/1=\u00a0
+FormatData/pt_GQ/latn.NumberElements/0=,
+FormatData/pt_GQ/latn.NumberElements/1=\u00a0
+FormatData/pt_MO/latn.NumberElements/0=,
+FormatData/pt_MO/latn.NumberElements/1=\u00a0
+FormatData/pt_LU/latn.NumberElements/0=,
+FormatData/pt_LU/latn.NumberElements/1=\u00a0
+FormatData/pt_MZ/latn.NumberElements/0=,
+FormatData/pt_MZ/latn.NumberElements/1=\u00a0
+FormatData/pt_ST/latn.NumberElements/0=,
+FormatData/pt_ST/latn.NumberElements/1=\u00a0
+FormatData/pt_TL/latn.NumberElements/0=,
+FormatData/pt_TL/latn.NumberElements/1=\u00a0
+FormatData/kea/latn.NumberElements/0=,
+FormatData/kea/latn.NumberElements/1=\u00a0
+FormatData/kea_CV/latn.NumberElements/0=,
+FormatData/kea_CV/latn.NumberElements/1=\u00a0
--- a/jdk/test/sun/text/resources/LocaleDataTest.java	Wed Jun 07 08:58:19 2017 -0700
+++ b/jdk/test/sun/text/resources/LocaleDataTest.java	Thu Jun 08 12:15:54 2017 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
  *      7003124 7085757 7028073 7171028 7189611 8000983 7195759 8004489 8006509
  *      7114053 7074882 7040556 8008577 8013836 8021121 6192407 6931564 8027695
  *      8017142 8037343 8055222 8042126 8074791 8075173 8080774 8129361 8134916
- *      8145136 8145952 8164784 8037111 8081643 7037368
+ *      8145136 8145952 8164784 8037111 8081643 7037368 8178872
  * @summary Verify locale data
  * @modules java.base/sun.util.resources
  * @modules jdk.localedata
@@ -99,8 +99,15 @@
  *        LocaleNames/fr_FR/US=\u00c9tats-Unis
  *        LocaleNames/fr_FR/FR=France</pre>
  *
- *    You can use language tag with '-' in locale field like this:<pre>
- *        LocaleNames/sr-Latn/SR=Surinam
+ *    Second field which designates locale is in the form of:
+ *    1) Legacy locale notation using '_' as a locale component(language/country/variant) separator.
+ *    language is a mandatory component. country and variant are optional, however,
+ *    variant cannot exist without country. So for example, while "ja"/"ja_JP"/"ja_JP_JP" are valid,
+ *    "_JP"/"ja__JP" are invalid.
+ *
+ *    2) BCP47 language tag notation in which we can specify language tag with '-' as a subtag
+ *       separator. Language tag can be specified with '-' in locale field like this:
+ *       <pre>LocaleNames/sr-Latn/SR=Surinam
  *        FormatData/sr-Latn-BA/DayNames/2=utorak</pre>
  *
  *    The command-line syntax of this test is
@@ -276,16 +283,25 @@
             throw new Exception("Malformed input file: \"" + key + "\" is missing locale name");
         localeName = key.substring(oldIndex, index);
         boolean use_tag = localeName.indexOf("-") != -1;
-
         if (use_tag == false && localeName.length() > 0) {
-            language = localeName.substring(0, 2);
-            if (localeName.length() > 3) {
-                country = localeName.substring(3, 5);
-                if (localeName.length() > 5)
-                    variant = localeName.substring(6);
+            String[] locDetails = localeName.split("_");
+            switch (locDetails.length) {
+                case 1:
+                    language = locDetails[0];
+                    break;
+                case 2:
+                    language = locDetails[0];
+                    country = locDetails[1];
+                    break;
+                case 3:
+                    language = locDetails[0];
+                    country = locDetails[1];
+                    variant = locDetails[2];
+                    break;
+                default:
+                    throw new Exception("locale not specified properly " + locDetails);
             }
         }
-
         oldIndex = index + 1;
         index = key.indexOf("/", oldIndex);
         if (index == -1)