changeset 53425:b58f3dee17d1

8218781: Localized names for Japanese era Reiwa in COMPAT provider Reviewed-by: naoto
author ljiang
date Sun, 19 May 2019 22:14:09 +0800
parents bf5adc66002a
children 5f41edd3513b
files src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_ar.java src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_ko.java src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_th.java src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_zh.java src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_ar.java src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_hi_IN.java src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_hr.java src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_in.java src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_ko.java src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_lt.java src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_nl.java src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_no.java src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_ru.java src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sr.java src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sr_Latn.java src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sv.java src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_th.java src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_zh.java src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_zh_TW.java test/jdk/java/util/Calendar/JapanEraNameCompatTest.java
diffstat 20 files changed, 174 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_ar.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_ar.java	Sun May 19 22:14:09 2019 +0800
@@ -212,6 +212,7 @@
                     "\u062a\u064a\u0634\u0648",
                     "\u0634\u0648\u0648\u0627",
                     "\u0647\u064a\u0633\u064a",
+                    "\u0631\u064a\u0648\u0627",
                 }
             },
             { "japanese.short.Eras",
@@ -221,6 +222,7 @@
                     "\u062a\u064a\u0634\u0648",
                     "\u0634\u0648\u0648\u0627",
                     "\u0647\u064a\u0633\u064a",
+                    "\u0631\u064a\u0648\u0627",
                 }
             },
             { "buddhist.Eras",
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_ko.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_ko.java	Sun May 19 22:14:09 2019 +0800
@@ -192,6 +192,7 @@
                     "\ub2e4\uc774\uc1fc",
                     "\uc1fc\uc640",
                     "\ud5e4\uc774\uc138\uc774",
+                    "\ub808\uc774\uc640",
                 }
             },
             { "AmPmMarkers",
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_th.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_th.java	Sun May 19 22:14:09 2019 +0800
@@ -245,6 +245,7 @@
                     "\u0e17\u0e30\u0e2d\u0e34\u0e42\u0e0a",
                     "\u0e42\u0e0a\u0e27\u0e30",
                     "\u0e40\u0e2e\u0e40\u0e0b",
+                    "\u0e40\u0e23\u0e27\u0e30",
                 }
             },
             { "japanese.short.Eras",
@@ -254,6 +255,7 @@
                     "\u0e17",
                     "\u0e0a",
                     "\u0e2e",
+                    "R",
                 }
             },
             { "buddhist.TimePatterns",
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_zh.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_zh.java	Sun May 19 22:14:09 2019 +0800
@@ -282,6 +282,7 @@
                     "\u5927\u6b63",
                     "\u662d\u548c",
                     "\u5e73\u6210",
+                    "\u4ee4\u548c",
                 }
             },
             { "TimePatterns",
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_ar.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_ar.java	Sun May 19 22:14:09 2019 +0800
@@ -157,6 +157,7 @@
             "\u062a\u064a\u0634\u0648",
             "\u0634\u0648\u0648\u0627",
             "\u0647\u064a\u0633\u064a",
+            "\u0631\u064a\u0648\u0627",
         };
 
         final String[] sharedShortEras = {
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_hi_IN.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_hi_IN.java	Sun May 19 22:14:09 2019 +0800
@@ -241,6 +241,7 @@
                     "\u0924\u093e\u0908\u0936\u094b",
                     "\u0936\u094b\u0935\u093e",
                     "\u0939\u0947\u0908\u0938\u0947\u0908",
+                    "\u0930\u0947\u0907\u0935\u093e",
                 }
             },
             { "java.time.japanese.short.Eras",
@@ -250,6 +251,7 @@
                     "\u0924\u093e\u0908\u0936\u094b",
                     "\u0936\u094b\u0935\u093e",
                     "\u0939\u0947\u0908\u0938\u0947\u0908",
+                    "\u0930\u0947\u0907\u0935\u093e",
                 }
             },
             { "java.time.long.Eras",
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_hr.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_hr.java	Sun May 19 22:14:09 2019 +0800
@@ -231,6 +231,7 @@
                     "Taish\u014d",
                     "Sh\u014dwa",
                     "Heisei",
+                    "Reiwa",
                 }
             },
             { "java.time.japanese.short.Eras",
@@ -240,6 +241,7 @@
                     "Taish\u014d",
                     "Sh\u014dwa",
                     "Heisei",
+                    "Reiwa",
                 }
             },
             { "java.time.long.Eras",
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_in.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_in.java	Sun May 19 22:14:09 2019 +0800
@@ -148,6 +148,7 @@
             "Taish\u014d",
             "Sh\u014dwa",
             "Heisei",
+            "Reiwa",
         };
 
         final String[] sharedEras = {
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_ko.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_ko.java	Sun May 19 22:14:09 2019 +0800
@@ -143,6 +143,7 @@
             "\ub2e4\uc774\uc1fc",
             "\uc1fc\uc640",
             "\ud5e4\uc774\uc138\uc774",
+            "\ub808\uc774\uc640",
         };
 
         final String[] sharedJavaTimeShortEras2 = {
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_lt.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_lt.java	Sun May 19 22:14:09 2019 +0800
@@ -223,6 +223,7 @@
                     "Tai\u0161o",
                     "\u0160ova",
                     "Heisei",
+                    "Reiwa",
                 }
             },
             { "java.time.japanese.short.Eras",
@@ -232,6 +233,7 @@
                     "Tai\u0161o",
                     "\u0160ova",
                     "Heisei",
+                    "Reiwa",
                 }
             },
             { "java.time.long.Eras",
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_nl.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_nl.java	Sun May 19 22:14:09 2019 +0800
@@ -265,6 +265,7 @@
                     "Taish\u014d",
                     "Sh\u014dwa",
                     "Heisei",
+                    "Reiwa",
                 }
             },
             { "java.time.japanese.short.Eras",
@@ -274,6 +275,7 @@
                     "Taish\u014d",
                     "Sh\u014dwa",
                     "Heisei",
+                    "Reiwa",
                 }
             },
             { "java.time.long.Eras",
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_no.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_no.java	Sun May 19 22:14:09 2019 +0800
@@ -283,6 +283,7 @@
                     "Taish\u014d",
                     "Sh\u014dwa",
                     "Heisei",
+                    "Reiwa",
                 }
             },
             { "java.time.japanese.short.Eras",
@@ -292,6 +293,7 @@
                     "T",
                     "S",
                     "H",
+                    "R",
                 }
             },
             { "java.time.long.Eras",
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_ru.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_ru.java	Sun May 19 22:14:09 2019 +0800
@@ -237,6 +237,7 @@
                     "\u042d\u043f\u043e\u0445\u0430 \u0422\u0430\u0439\u0441\u044c\u043e",
                     "\u0421\u044c\u043e\u0432\u0430",
                     "\u042d\u043f\u043e\u0445\u0430 \u0425\u044d\u0439\u0441\u044d\u0439",
+                    "\u0420\u044d\u0439\u0432\u0430",
                 }
             },
             { "java.time.japanese.short.Eras",
@@ -246,6 +247,7 @@
                     "\u042d\u043f\u043e\u0445\u0430 \u0422\u0430\u0439\u0441\u044c\u043e",
                     "\u0421\u044c\u043e\u0432\u0430",
                     "\u042d\u043f\u043e\u0445\u0430 \u0425\u044d\u0439\u0441\u044d\u0439",
+                    "\u0420\u044d\u0439\u0432\u0430",
                 }
             },
             { "java.time.long.Eras",
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sr.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sr.java	Sun May 19 22:14:09 2019 +0800
@@ -280,6 +280,7 @@
                     "\u0422\u0430\u0438\u0448\u043e",
                     "\u0428\u043e\u0432\u0430",
                     "\u0425\u0430\u0438\u0441\u0435\u0438",
+                    "\u0420\u0435\u0438\u0432\u0430",
                 }
             },
             { "java.time.japanese.short.Eras",
@@ -289,6 +290,7 @@
                     "\u0422\u0430\u0438\u0448\u043e",
                     "\u0428\u043e\u0432\u0430",
                     "\u0425\u0430\u0438\u0441\u0435\u0438",
+                    "\u0420\u0435\u0438\u0432\u0430",
                 }
             },
             { "java.time.long.Eras",
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sr_Latn.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sr_Latn.java	Sun May 19 22:14:09 2019 +0800
@@ -225,6 +225,7 @@
                     "Tai\u0161o",
                     "\u0160ova",
                     "Haisei",
+                    "Reiva",
                 }
             },
             { "java.time.japanese.short.Eras",
@@ -234,6 +235,7 @@
                     "Tai\u0161o",
                     "\u0160ova",
                     "Haisei",
+                    "Reiva",
                 }
             },
             { "java.time.long.Eras",
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sv.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_sv.java	Sun May 19 22:14:09 2019 +0800
@@ -249,6 +249,7 @@
                     "Taish\u014d",
                     "Sh\u014dwa",
                     "Heisei",
+                    "Reiwa",
                 }
             },
             { "java.time.japanese.short.Eras",
@@ -258,6 +259,7 @@
                     "Taish\u014d",
                     "Sh\u014dwa",
                     "Heisei",
+                    "Reiwa",
                 }
             },
             { "java.time.long.Eras",
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_th.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_th.java	Sun May 19 22:14:09 2019 +0800
@@ -137,6 +137,7 @@
             "\u0e17\u0e30\u0e2d\u0e34\u0e42\u0e0a",
             "\u0e42\u0e0a\u0e27\u0e30",
             "\u0e40\u0e2e\u0e40\u0e0b",
+            "\u0e40\u0e23\u0e27\u0e30",
         };
 
         final String[] sharedShortEras = {
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_zh.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_zh.java	Sun May 19 22:14:09 2019 +0800
@@ -176,6 +176,7 @@
             "\u5927\u6b63",
             "\u662d\u548c",
             "\u5e73\u6210",
+            "\u4ee4\u548c",
         };
 
         final String[] sharedJavaTimeShortEras2 = {
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_zh_TW.java	Tue May 21 15:18:33 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_zh_TW.java	Sun May 19 22:14:09 2019 +0800
@@ -135,6 +135,7 @@
             "\u5927\u6b63",
             "\u662d\u548c",
             "\u5e73\u6210",
+            "\u4ee4\u548c",
         };
 
         final String[] sharedJavaTimeShortEras2 = {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/util/Calendar/JapanEraNameCompatTest.java	Sun May 19 22:14:09 2019 +0800
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2019, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8218781
+ * @summary Test the localized names of Japanese era Reiwa from COMPAT provider.
+ * @modules jdk.localedata
+ * @run testng/othervm -Djava.locale.providers=COMPAT JapanEraNameCompatTest
+ */
+
+import static java.util.Calendar.*;
+import static java.util.Locale.*;
+
+import java.time.LocalDate;
+import java.time.chrono.JapaneseChronology;
+import java.time.chrono.JapaneseEra;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+import java.time.format.TextStyle;
+import java.util.Calendar;
+import java.util.Locale;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertEquals;
+
+@Test
+public class JapanEraNameCompatTest {
+    static final Calendar c = new Calendar.Builder()
+            .setCalendarType("japanese")
+            .setFields(ERA, 5, YEAR, 1, MONTH, MAY, DAY_OF_MONTH, 1)
+            .build();
+    static final String EngName = "Reiwa";
+    static final String CJName = "\u4ee4\u548c";
+    static final String KoreanName = "\ub808\uc774\uc640";
+    static final String ArabicName = "\u0631\u064a\u0648\u0627";
+    static final String ThaiName = "\u0e40\u0e23\u0e27\u0e30";
+    static final String HindiName = "\u0930\u0947\u0907\u0935\u093e";
+    static final String RussianName = "\u0420\u044d\u0439\u0432\u0430";
+    static final String SerbianName = "\u0420\u0435\u0438\u0432\u0430";
+    static final String SerbLatinName = "Reiva";
+
+    @DataProvider(name="UtilCalendar")
+    Object[][] dataUtilCalendar() {
+        return new Object[][] {
+            //locale,   long,       short
+            { JAPAN,    CJName,     "R" },
+            { KOREAN,   KoreanName, "R" },
+            { CHINA,    CJName,     "R" },
+            { TAIWAN,   CJName,     "R" }, // fallback to zh
+            { new Locale("ar"), ArabicName, ArabicName },
+            { new Locale("th"), ThaiName, "R" },
+            // hi_IN fallback to root
+            { new Locale("hi", "IN"), EngName, "R" }
+        };
+    }
+
+    @Test(dataProvider="UtilCalendar")
+    public void testCalendarEraDisplayName(Locale locale,
+            String longName, String shortName) {
+        assertEquals(c.getDisplayName(ERA, LONG, locale), longName);
+        assertEquals(c.getDisplayName(ERA, SHORT, locale), shortName);
+    }
+
+    @DataProvider(name="JavaTime")
+    Object[][] dataJavaTime() {
+        return new Object[][] {
+            // locale, full, short
+            { JAPAN, CJName, CJName },
+            { KOREAN, KoreanName, KoreanName },
+            { CHINA, CJName, CJName },
+            { TAIWAN, CJName, CJName },
+            { new Locale("ar"), ArabicName, ArabicName },
+            { new Locale("th"), ThaiName, ThaiName },
+            { new Locale("hi", "IN"), HindiName, HindiName },
+            { new Locale("ru"), RussianName, RussianName },
+            { new Locale("sr"), SerbianName, SerbianName },
+            { Locale.forLanguageTag("sr-Latn"), SerbLatinName, SerbLatinName },
+            { new Locale("hr"), EngName, EngName },
+            { new Locale("in"), EngName, EngName },
+            { new Locale("lt"), EngName, EngName },
+            { new Locale("nl"), EngName, EngName },
+            { new Locale("no"), EngName, "R" },
+            { new Locale("sv"), EngName, EngName },
+            // el fallback to root
+            { new Locale("el"), EngName, EngName }
+        };
+    }
+
+    @Test(dataProvider="JavaTime")
+    public void testChronoJapanEraDisplayName(Locale locale,
+            String fullName, String shortName) {
+
+        JapaneseEra era = JapaneseEra.valueOf("Reiwa");
+        assertEquals(era.getDisplayName(TextStyle.FULL, locale), fullName);
+        assertEquals(era.getDisplayName(TextStyle.SHORT, locale), shortName);
+        assertEquals(era.getDisplayName(TextStyle.NARROW, locale), "R");
+    }
+
+    @Test
+    public void testFormatParseEraName() {
+        LocalDate date = LocalDate.of(2019, 5, 1);
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy MM dd GGGG");
+        formatter = formatter.withChronology(JapaneseChronology.INSTANCE);
+
+        int num = 0;
+        for (Locale locale : Calendar.getAvailableLocales()) {
+            formatter = formatter.withLocale(locale);
+            try {
+                LocalDate.parse(date.format(formatter), formatter);
+            } catch (DateTimeParseException e) {
+                // If an array is defined for Japanese eras in java.time resource,
+                // but an era entry is missing, format fallback to English name
+                // while parse throw DateTimeParseException.
+                num++;
+                System.out.println("Missing java.time resource data for locale: " + locale);
+            }
+        }
+        if (num > 0) {
+            throw new RuntimeException("Missing java.time data for " + num + " locales");
+        }
+    }
+}