mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8174269: Remove COMPAT locale data provider from JDK
Reviewed-by: ihse, joehw
This commit is contained in:
parent
c6641c7d2d
commit
809995b526
565 changed files with 1106 additions and 67327 deletions
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2014, 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
|
||||
* (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
|
||||
*
|
||||
* The original version of this source code and documentation
|
||||
* is copyrighted and owned by Taligent, Inc., a wholly-owned
|
||||
* subsidiary of IBM. These materials are provided under terms
|
||||
* of a License Agreement between Taligent and Sun. This technology
|
||||
* is protected by multiple US and International patents.
|
||||
*
|
||||
* This notice and attribution to Taligent may not be removed.
|
||||
* Taligent is a registered trademark of Taligent, Inc.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.text.resources;
|
||||
|
||||
import sun.util.resources.ParallelListResourceBundle;
|
||||
|
||||
public class FormatData_en extends ParallelListResourceBundle {
|
||||
/**
|
||||
* Overrides ParallelListResourceBundle
|
||||
*/
|
||||
protected final Object[][] getContents() {
|
||||
// This locale inherits almost everything from the root default locale. However,
|
||||
// even if it inherited everything, we would still need this locale to exist
|
||||
// to make the resource-bundle lookup mechanism work right. In that case, we'd
|
||||
// define this method as follows:
|
||||
// return new Object[][] { };
|
||||
return new Object[][] {
|
||||
{ "MonthNarrows",
|
||||
new String[] {
|
||||
"J",
|
||||
"F",
|
||||
"M",
|
||||
"A",
|
||||
"M",
|
||||
"J",
|
||||
"J",
|
||||
"A",
|
||||
"S",
|
||||
"O",
|
||||
"N",
|
||||
"D",
|
||||
"",
|
||||
}
|
||||
},
|
||||
{ "NumberPatterns",
|
||||
new String[] {
|
||||
"#,##0.###;-#,##0.###", // decimal pattern
|
||||
"\u00A4#,##0.00;-\u00A4#,##0.00", // currency pattern
|
||||
"#,##0%" // percent pattern
|
||||
}
|
||||
},
|
||||
{ "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" },
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2013, 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
|
||||
* (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
|
||||
*
|
||||
* The original version of this source code and documentation
|
||||
* is copyrighted and owned by Taligent, Inc., a wholly-owned
|
||||
* subsidiary of IBM. These materials are provided under terms
|
||||
* of a License Agreement between Taligent and Sun. This technology
|
||||
* is protected by multiple US and International patents.
|
||||
*
|
||||
* This notice and attribution to Taligent may not be removed.
|
||||
* Taligent is a registered trademark of Taligent, Inc.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.text.resources;
|
||||
|
||||
import sun.util.resources.ParallelListResourceBundle;
|
||||
|
||||
public class FormatData_en_US extends ParallelListResourceBundle {
|
||||
/**
|
||||
* Overrides ParallelListResourceBundle
|
||||
*/
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "NumberPatterns",
|
||||
new String[] {
|
||||
"#,##0.###;-#,##0.###", // decimal pattern
|
||||
"\u00a4#,##0.00;(\u00a4#,##0.00)", // currency pattern
|
||||
"#,##0%" // percent pattern
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,274 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2016, 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT AND PERMISSION NOTICE
|
||||
*
|
||||
* Copyright (C) 1991-2016 Unicode, Inc. All rights reserved.
|
||||
* Distributed under the Terms of Use in
|
||||
* http://www.unicode.org/copyright.html.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of the Unicode data files and any associated documentation
|
||||
* (the "Data Files") or Unicode software and any associated documentation
|
||||
* (the "Software") to deal in the Data Files or Software
|
||||
* without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, and/or sell copies of
|
||||
* the Data Files or Software, and to permit persons to whom the Data Files
|
||||
* or Software are furnished to do so, provided that
|
||||
* (a) this copyright and permission notice appear with all copies
|
||||
* of the Data Files or Software,
|
||||
* (b) this copyright and permission notice appear in associated
|
||||
* documentation, and
|
||||
* (c) there is clear notice in each modified Data File or in the Software
|
||||
* as well as in the documentation associated with the Data File(s) or
|
||||
* Software that the data or software has been modified.
|
||||
*
|
||||
* THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
* ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
|
||||
* NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
|
||||
* DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THE DATA FILES OR SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale,
|
||||
* use or other dealings in these Data Files or Software without prior
|
||||
* written authorization of the copyright holder.
|
||||
*/
|
||||
|
||||
// Note: this file has been generated by a tool.
|
||||
|
||||
package sun.text.resources;
|
||||
|
||||
import sun.util.resources.OpenListResourceBundle;
|
||||
|
||||
public class JavaTimeSupplementary_en extends OpenListResourceBundle {
|
||||
@Override
|
||||
protected final Object[][] getContents() {
|
||||
final String[] sharedQuarterNames = {
|
||||
"1st quarter",
|
||||
"2nd quarter",
|
||||
"3rd quarter",
|
||||
"4th quarter",
|
||||
};
|
||||
|
||||
final String[] sharedDatePatterns = {
|
||||
"EEEE, MMMM d, y GGGG",
|
||||
"MMMM d, y GGGG",
|
||||
"MMM d, y GGGG",
|
||||
"M/d/y G",
|
||||
};
|
||||
|
||||
final String[] sharedDayNames = {
|
||||
"Sunday",
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday",
|
||||
};
|
||||
|
||||
final String[] sharedQuarterAbbreviations = {
|
||||
"Q1",
|
||||
"Q2",
|
||||
"Q3",
|
||||
"Q4",
|
||||
};
|
||||
|
||||
final String[] sharedTimePatterns = {
|
||||
"h:mm:ss a zzzz",
|
||||
"h:mm:ss a z",
|
||||
"h:mm:ss a",
|
||||
"h:mm a",
|
||||
};
|
||||
|
||||
final String[] sharedNarrowAmPmMarkers = {
|
||||
"a",
|
||||
"p",
|
||||
};
|
||||
|
||||
final String[] sharedJavaTimeDatePatterns = {
|
||||
"EEEE, MMMM d, y G",
|
||||
"MMMM d, y G",
|
||||
"MMM d, y G",
|
||||
"M/d/y GGGGG",
|
||||
};
|
||||
|
||||
final String[] sharedEras = {
|
||||
"Before R.O.C.",
|
||||
"Minguo",
|
||||
};
|
||||
|
||||
return new Object[][] {
|
||||
{ "QuarterNames",
|
||||
sharedQuarterNames },
|
||||
{ "calendarname.buddhist",
|
||||
"Buddhist Calendar" },
|
||||
{ "calendarname.gregorian",
|
||||
"Gregorian Calendar" },
|
||||
{ "calendarname.gregory",
|
||||
"Gregorian Calendar" },
|
||||
{ "calendarname.islamic",
|
||||
"Islamic Calendar" },
|
||||
{ "calendarname.islamic-civil",
|
||||
"Islamic Calendar (tabular, civil epoch)" },
|
||||
{ "calendarname.islamic-umalqura",
|
||||
"Islamic Calendar (Umm al-Qura)" },
|
||||
{ "calendarname.japanese",
|
||||
"Japanese Calendar" },
|
||||
{ "calendarname.roc",
|
||||
"Minguo Calendar" },
|
||||
{ "field.dayperiod",
|
||||
"AM/PM" },
|
||||
{ "field.era",
|
||||
"era" },
|
||||
{ "field.hour",
|
||||
"hour" },
|
||||
{ "field.minute",
|
||||
"minute" },
|
||||
{ "field.month",
|
||||
"month" },
|
||||
{ "field.second",
|
||||
"second" },
|
||||
{ "field.week",
|
||||
"week" },
|
||||
{ "field.weekday",
|
||||
"day of the week" },
|
||||
{ "field.year",
|
||||
"year" },
|
||||
{ "field.zone",
|
||||
"time zone" },
|
||||
{ "islamic.AmPmMarkers",
|
||||
new String[] {
|
||||
"AM",
|
||||
"PM",
|
||||
}
|
||||
},
|
||||
{ "islamic.DatePatterns",
|
||||
sharedDatePatterns },
|
||||
{ "islamic.DayNames",
|
||||
sharedDayNames },
|
||||
{ "islamic.QuarterAbbreviations",
|
||||
sharedQuarterAbbreviations },
|
||||
{ "islamic.QuarterNames",
|
||||
sharedQuarterNames },
|
||||
{ "islamic.TimePatterns",
|
||||
sharedTimePatterns },
|
||||
{ "islamic.narrow.AmPmMarkers",
|
||||
sharedNarrowAmPmMarkers },
|
||||
{ "java.time.buddhist.DatePatterns",
|
||||
sharedJavaTimeDatePatterns },
|
||||
{ "java.time.buddhist.short.Eras",
|
||||
new String[] {
|
||||
"BC",
|
||||
"BE",
|
||||
}
|
||||
},
|
||||
{ "java.time.islamic.DatePatterns",
|
||||
sharedJavaTimeDatePatterns },
|
||||
{ "java.time.japanese.DatePatterns",
|
||||
sharedJavaTimeDatePatterns },
|
||||
{ "java.time.long.Eras",
|
||||
new String[] {
|
||||
"Before Christ",
|
||||
"Anno Domini",
|
||||
}
|
||||
},
|
||||
{ "java.time.roc.DatePatterns",
|
||||
sharedJavaTimeDatePatterns },
|
||||
{ "roc.DatePatterns",
|
||||
sharedDatePatterns },
|
||||
{ "roc.DayAbbreviations",
|
||||
new String[] {
|
||||
"Sun",
|
||||
"Mon",
|
||||
"Tue",
|
||||
"Wed",
|
||||
"Thu",
|
||||
"Fri",
|
||||
"Sat",
|
||||
}
|
||||
},
|
||||
{ "roc.DayNames",
|
||||
sharedDayNames },
|
||||
{ "roc.Eras",
|
||||
sharedEras },
|
||||
{ "roc.MonthNames",
|
||||
new String[] {
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December",
|
||||
"",
|
||||
}
|
||||
},
|
||||
{ "roc.MonthNarrows",
|
||||
new String[] {
|
||||
"J",
|
||||
"F",
|
||||
"M",
|
||||
"A",
|
||||
"M",
|
||||
"J",
|
||||
"J",
|
||||
"A",
|
||||
"S",
|
||||
"O",
|
||||
"N",
|
||||
"D",
|
||||
"",
|
||||
}
|
||||
},
|
||||
{ "roc.QuarterAbbreviations",
|
||||
sharedQuarterAbbreviations },
|
||||
{ "roc.QuarterNames",
|
||||
sharedQuarterNames },
|
||||
{ "roc.TimePatterns",
|
||||
sharedTimePatterns },
|
||||
{ "roc.long.Eras",
|
||||
sharedEras },
|
||||
{ "roc.narrow.AmPmMarkers",
|
||||
sharedNarrowAmPmMarkers },
|
||||
{ "roc.narrow.Eras",
|
||||
sharedEras },
|
||||
{ "roc.short.Eras",
|
||||
sharedEras },
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2024, 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
|
||||
|
@ -28,6 +28,8 @@ package sun.util.cldr;
|
|||
import static sun.util.locale.provider.LocaleProviderAdapter.Type;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
@ -154,10 +156,15 @@ public class CLDRTimeZoneNameProviderImpl extends TimeZoneNameProviderImpl {
|
|||
var cands = ((CLDRLocaleProviderAdapter)LocaleProviderAdapter.forType(Type.CLDR))
|
||||
.getCandidateLocales("", locale);
|
||||
for (int i = 1; i < cands.size() ; i++) {
|
||||
String[] parentNames = super.getDisplayNameArray(id, cands.get(i));
|
||||
var loc = cands.get(i);
|
||||
String[] parentNames = super.getDisplayNameArray(id, loc);
|
||||
if (parentNames != null && !parentNames[index].isEmpty()) {
|
||||
names[index] = parentNames[index];
|
||||
return;
|
||||
// Long names in ROOT locale should not be copied, as they can be generated
|
||||
// with the fallback mechanisms below
|
||||
if (!loc.equals(Locale.ROOT) || index % 2 == 0) {
|
||||
names[index] = parentNames[index];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -167,19 +174,6 @@ public class CLDRTimeZoneNameProviderImpl extends TimeZoneNameProviderImpl {
|
|||
return;
|
||||
}
|
||||
|
||||
// Check if COMPAT can substitute the name
|
||||
if (!exists(names, index) &&
|
||||
LocaleProviderAdapter.getAdapterPreference().contains(Type.JRE)) {
|
||||
String[] compatNames = (String[])LocaleProviderAdapter.forJRE()
|
||||
.getLocaleResources(mapChineseLocale(locale))
|
||||
.getTimeZoneNames(id);
|
||||
if (compatNames != null) {
|
||||
// Assumes COMPAT has no empty slots
|
||||
names[index] = compatNames[index];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Region Fallback
|
||||
if (regionFormatFallback(names, index, locale)) {
|
||||
return;
|
||||
|
@ -270,8 +264,18 @@ public class CLDRTimeZoneNameProviderImpl extends TimeZoneNameProviderImpl {
|
|||
}
|
||||
|
||||
private String toGMTFormat(String id, boolean daylight, Locale l) {
|
||||
TimeZone tz = ZoneInfoFile.getZoneInfo(id);
|
||||
int offset = (tz.getRawOffset() + (daylight ? tz.getDSTSavings() : 0)) / 60000;
|
||||
var zr = ZoneInfoFile.getZoneInfo(id).toZoneId().getRules();
|
||||
var now = Instant.now();
|
||||
var saving = zr.getTransitions().reversed().stream()
|
||||
.dropWhile(zot -> zot.getInstant().isAfter(now))
|
||||
.filter(zot -> zr.isDaylightSavings(zot.getInstant()))
|
||||
.findFirst()
|
||||
.map(zot -> zr.getDaylightSavings(zot.getInstant()))
|
||||
.map(Duration::getSeconds)
|
||||
.map(Long::intValue)
|
||||
.orElse(0);
|
||||
int offset = (zr.getStandardOffset(now).getTotalSeconds() +
|
||||
(daylight ? saving : 0)) / 60;
|
||||
LocaleResources lr = LocaleProviderAdapter.forType(Type.CLDR).getLocaleResources(l);
|
||||
ResourceBundle fd = lr.getJavaTimeFormatData();
|
||||
|
||||
|
@ -294,33 +298,4 @@ public class CLDRTimeZoneNameProviderImpl extends TimeZoneNameProviderImpl {
|
|||
String.format(l, hourFormat, offset / 60, offset % 60));
|
||||
}
|
||||
}
|
||||
|
||||
// Mapping CLDR's Simplified/Traditional Chinese resources
|
||||
// to COMPAT's zh-CN/TW
|
||||
private Locale mapChineseLocale(Locale locale) {
|
||||
if (locale.getLanguage() == "zh") {
|
||||
switch (locale.getScript()) {
|
||||
case "Hans":
|
||||
return Locale.CHINA;
|
||||
case "Hant":
|
||||
return Locale.TAIWAN;
|
||||
case "":
|
||||
// no script, guess from country code.
|
||||
switch (locale.getCountry()) {
|
||||
case "":
|
||||
case "CN":
|
||||
case "SG":
|
||||
return Locale.CHINA;
|
||||
case "HK":
|
||||
case "MO":
|
||||
case "TW":
|
||||
return Locale.TAIWAN;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// no need to map
|
||||
return locale;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2024, 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
|
||||
|
@ -23,58 +23,49 @@
|
|||
* questions.
|
||||
*/
|
||||
|
||||
#warn This file is preprocessed before being compiled
|
||||
|
||||
/*
|
||||
* This class contains a map which records the locale list string for
|
||||
* each resource in sun.util.resources & sun.text.resources.
|
||||
* It is used to avoid loading non-existent localized resources so that
|
||||
* jar files won't be opened unnecessary to look up them.
|
||||
* jar files won't be opened unnecessarily to look up them.
|
||||
*/
|
||||
package #Package#;
|
||||
package sun.util.locale.provider;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import sun.util.locale.provider.LocaleDataMetaInfo;
|
||||
import static sun.util.locale.provider.LocaleProviderAdapter.Type;
|
||||
|
||||
public class #Lang#LocaleDataMetaInfo implements LocaleDataMetaInfo {
|
||||
public class BaseLocaleDataMetaInfo implements LocaleDataMetaInfo {
|
||||
|
||||
private static final Map<String, String> resourceNameToLocales = new HashMap<>(9);
|
||||
private static final Map<String, String> resourceNameToLocales = HashMap.newHashMap(9);
|
||||
|
||||
static {
|
||||
/* During JDK build time, #XXX_YYY# will be replaced by a string contain all the locales
|
||||
supported by the resource.
|
||||
|
||||
Don't remove the space character between " and #. That is put there purposely so that
|
||||
look up locale string such as "en" could be based on if it contains " en ".
|
||||
*/
|
||||
resourceNameToLocales.put("FormatData",
|
||||
" #FormatData_Locales# ");
|
||||
" en en-US ");
|
||||
|
||||
resourceNameToLocales.put("CollationData",
|
||||
" #CollationData_Locales# ");
|
||||
" ");
|
||||
|
||||
resourceNameToLocales.put("BreakIteratorInfo",
|
||||
" #BreakIteratorInfo_Locales# ");
|
||||
" ");
|
||||
|
||||
resourceNameToLocales.put("BreakIteratorRules",
|
||||
" #BreakIteratorRules_Locales# ");
|
||||
" ");
|
||||
|
||||
resourceNameToLocales.put("TimeZoneNames",
|
||||
" #TimeZoneNames_Locales# ");
|
||||
" en ");
|
||||
|
||||
resourceNameToLocales.put("LocaleNames",
|
||||
" #LocaleNames_Locales# ");
|
||||
" en ");
|
||||
|
||||
resourceNameToLocales.put("CurrencyNames",
|
||||
" #CurrencyNames_Locales# ");
|
||||
" en-US ");
|
||||
|
||||
resourceNameToLocales.put("CalendarData",
|
||||
" #CalendarData_Locales# ");
|
||||
" en ");
|
||||
|
||||
resourceNameToLocales.put("AvailableLocales",
|
||||
" #AvailableLocales_Locales# ");
|
||||
" en en-US ");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -91,7 +82,7 @@ public class #Lang#LocaleDataMetaInfo implements LocaleDataMetaInfo {
|
|||
@Override
|
||||
public Type getType() {
|
||||
return Type.JRE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String availableLanguageTags(String category) {
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2024, 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
|
||||
|
@ -84,29 +84,17 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av
|
|||
Era[] jeras = CalendarSystem.forName("japanese").getEras();
|
||||
if (value <= jeras.length) {
|
||||
// Localized era name could not be retrieved from this provider.
|
||||
// This can occur either for Reiwa or SupEra.
|
||||
//
|
||||
// If it's CLDR provider, try COMPAT first, which is guaranteed to have
|
||||
// the name for Reiwa.
|
||||
if (type == LocaleProviderAdapter.Type.CLDR) {
|
||||
lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale);
|
||||
key = getResourceKeyFor(LocaleProviderAdapter.Type.JRE,
|
||||
calendarType, field, style, javatime);
|
||||
strings =
|
||||
javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key);
|
||||
}
|
||||
if (strings == null || value >= strings.length) {
|
||||
// Get the default name for SupEra
|
||||
Era supEra = jeras[value - 1]; // 0-based index
|
||||
if (javatime) {
|
||||
return getBaseStyle(style) == NARROW_FORMAT ?
|
||||
supEra.getAbbreviation() :
|
||||
supEra.getName();
|
||||
} else {
|
||||
return (style & LONG) != 0 ?
|
||||
supEra.getName() :
|
||||
supEra.getAbbreviation();
|
||||
}
|
||||
// This can occur for SupEra.
|
||||
// Get the default name for SupEra
|
||||
Era supEra = jeras[value - 1]; // 0-based index
|
||||
if (javatime) {
|
||||
return getBaseStyle(style) == NARROW_FORMAT ?
|
||||
supEra.getAbbreviation() :
|
||||
supEra.getName();
|
||||
} else {
|
||||
return (style & LONG) != 0 ?
|
||||
supEra.getName() :
|
||||
supEra.getAbbreviation();
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
|
@ -314,7 +302,7 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av
|
|||
// JRE and CLDR use different resource key conventions
|
||||
// due to historical reasons. (JRE DateFormatSymbols.getEras returns
|
||||
// abbreviations while other getShort*() return abbreviations.)
|
||||
if (adapterType == LocaleProviderAdapter.Type.JRE) {
|
||||
if (adapterType == LocaleProviderAdapter.Type.FALLBACK) {
|
||||
if (javatime) {
|
||||
if (baseStyle == LONG) {
|
||||
key.append("long.");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2024, 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
|
||||
|
@ -25,29 +25,30 @@
|
|||
|
||||
package sun.util.locale.provider;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.text.spi.BreakIteratorProvider;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* FallbackProviderAdapter implementation.
|
||||
/*
|
||||
* FallbackProviderAdapter implementation. Fallback provider serves the
|
||||
* following purposes:
|
||||
*
|
||||
* @author Naoto Sato
|
||||
* - Locale data for ROOT, in case CLDR provider is absent.
|
||||
* - Locale data for BreakIterator/Collator resources for all locales.
|
||||
* - "Gan-nen" support for SimpleDateFormat (provides "FirstYear" for
|
||||
* Japanese locales).
|
||||
*/
|
||||
public class FallbackLocaleProviderAdapter extends JRELocaleProviderAdapter {
|
||||
// Required locales/langtags
|
||||
private static final Locale[] AVAILABLE_LOCS = {Locale.US, Locale.ENGLISH, Locale.ROOT};
|
||||
private static final Set<String> AVAILABLE_LANGTAGS = Set.of("en-US", "en", "und");
|
||||
|
||||
/**
|
||||
* Supported language tag set.
|
||||
*/
|
||||
private static final Set<String> rootTagSet =
|
||||
Collections.singleton(Locale.ROOT.toLanguageTag());
|
||||
|
||||
/**
|
||||
* Fallback provider only provides the ROOT locale data.
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
private final LocaleResources rootLocaleResources =
|
||||
new LocaleResources(this, Locale.ROOT);
|
||||
private volatile BreakIteratorProvider breakIteratorProvider;
|
||||
|
||||
/**
|
||||
* Returns the type of this LocaleProviderAdapter
|
||||
|
@ -58,17 +59,45 @@ public class FallbackLocaleProviderAdapter extends JRELocaleProviderAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public LocaleResources getLocaleResources(Locale locale) {
|
||||
return rootLocaleResources;
|
||||
public Locale[] getAvailableLocales() {
|
||||
return Stream.concat(Arrays.stream(super.getAvailableLocales()), Stream.of(AVAILABLE_LOCS))
|
||||
.distinct().toArray(Locale[]::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<String> createLanguageTagSet(String category) {
|
||||
return rootTagSet;
|
||||
var s = new HashSet<>(super.createLanguageTagSet(category));
|
||||
s.addAll(AVAILABLE_LANGTAGS);
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSupportedProviderLocale(Locale locale, Set<String>langtags) {
|
||||
return Locale.ROOT.equals(locale);
|
||||
public boolean isSupportedProviderLocale(Locale locale, Set<String> langtags) {
|
||||
if (Locale.ROOT.equals(locale)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
locale = locale.stripExtensions();
|
||||
return langtags.contains(locale.toLanguageTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
// In order to correctly report supported locales
|
||||
public BreakIteratorProvider getBreakIteratorProvider() {
|
||||
if (breakIteratorProvider == null) {
|
||||
@SuppressWarnings("removal")
|
||||
BreakIteratorProvider provider = AccessController.doPrivileged(
|
||||
(PrivilegedAction<BreakIteratorProvider>) () ->
|
||||
new BreakIteratorProviderImpl(
|
||||
getAdapterType(),
|
||||
getLanguageTagSet("BreakIteratorRules")));
|
||||
|
||||
synchronized (this) {
|
||||
if (breakIteratorProvider == null) {
|
||||
breakIteratorProvider = provider;
|
||||
}
|
||||
}
|
||||
}
|
||||
return breakIteratorProvider;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2024, 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
|
||||
|
@ -470,7 +470,7 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
|
|||
if (ldmi.getType() == LocaleProviderAdapter.Type.JRE) {
|
||||
String t = ldmi.availableLanguageTags(category);
|
||||
if (t != null) {
|
||||
if (tags.length() > 0) {
|
||||
if (!tags.isEmpty()) {
|
||||
tags.append(' ');
|
||||
}
|
||||
tags.append(t);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2024, 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
|
||||
|
@ -126,8 +126,7 @@ public abstract class LocaleProviderAdapter {
|
|||
for (String type : types) {
|
||||
type = type.trim().toUpperCase(Locale.ROOT);
|
||||
if (type.equals("COMPAT") || type.equals("JRE")) {
|
||||
compatWarningMessage = "COMPAT locale provider will be removed in a future release";
|
||||
type = "JRE";
|
||||
compatWarningMessage = "COMPAT locale provider has been removed";
|
||||
}
|
||||
try {
|
||||
Type aType = Type.valueOf(type.trim().toUpperCase(Locale.ROOT));
|
||||
|
@ -141,17 +140,14 @@ public abstract class LocaleProviderAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
if (!typeList.isEmpty()) {
|
||||
// bona fide preference exists
|
||||
if (!(typeList.contains(Type.CLDR) || typeList.contains(Type.JRE))) {
|
||||
// Append FALLBACK as the last resort when no ResourceBundleBasedAdapter is available.
|
||||
typeList.add(Type.FALLBACK);
|
||||
}
|
||||
} else {
|
||||
if (typeList.isEmpty()) {
|
||||
// Default preference list.
|
||||
typeList.add(Type.CLDR);
|
||||
typeList.add(Type.JRE);
|
||||
}
|
||||
|
||||
// always append FALLBACK
|
||||
typeList.add(Type.FALLBACK);
|
||||
|
||||
adapterPreference = Collections.unmodifiableList(typeList);
|
||||
|
||||
// Emit logs, if any, after 'adapterPreference' is initialized which is needed
|
||||
|
@ -307,14 +303,13 @@ public abstract class LocaleProviderAdapter {
|
|||
|
||||
public static Locale[] toLocaleArray(Set<String> tags) {
|
||||
return tags.stream()
|
||||
.map(t -> {
|
||||
return switch (t) {
|
||||
case "ja-JP-JP" -> JRELocaleConstants.JA_JP_JP;
|
||||
case "no-NO-NY" -> JRELocaleConstants.NO_NO_NY;
|
||||
case "th-TH-TH" -> JRELocaleConstants.TH_TH_TH;
|
||||
default -> Locale.forLanguageTag(t);
|
||||
};
|
||||
.map(t -> switch (t) {
|
||||
case "ja-JP-JP" -> JRELocaleConstants.JA_JP_JP;
|
||||
case "no-NO-NY" -> JRELocaleConstants.NO_NO_NY;
|
||||
case "th-TH-TH" -> JRELocaleConstants.TH_TH_TH;
|
||||
default -> Locale.forLanguageTag(t);
|
||||
})
|
||||
.distinct()
|
||||
.toArray(Locale[]::new);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
#
|
||||
# Copyright (c) 2005, 2012, 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. Oracle designates this
|
||||
# particular file as subject to the "Classpath" exception as provided
|
||||
# by Oracle in the LICENSE file that accompanied this code.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
|
||||
# (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved
|
||||
#
|
||||
# The original version of this source code and documentation
|
||||
# is copyrighted and owned by Taligent, Inc., a wholly-owned
|
||||
# subsidiary of IBM. These materials are provided under terms
|
||||
# of a License Agreement between Taligent and Sun. This technology
|
||||
# is protected by multiple US and International patents.
|
||||
#
|
||||
# This notice and attribution to Taligent may not be removed.
|
||||
# Taligent is a registered trademark of Taligent, Inc.
|
||||
|
||||
|
||||
# This bundle is empty because the data of the base bundle
|
||||
# is adequate for this locale.
|
||||
# The bundle is necessary to prevent the resource
|
||||
# bundle lookup from falling back to the default
|
||||
# locale.
|
|
@ -1,38 +0,0 @@
|
|||
#
|
||||
# Copyright (c) 2005, 2012, 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. Oracle designates this
|
||||
# particular file as subject to the "Classpath" exception as provided
|
||||
# by Oracle in the LICENSE file that accompanied this code.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
|
||||
# (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved
|
||||
#
|
||||
# The original version of this source code and documentation
|
||||
# is copyrighted and owned by Taligent, Inc., a wholly-owned
|
||||
# subsidiary of IBM. These materials are provided under terms
|
||||
# of a License Agreement between Taligent and Sun. This technology
|
||||
# is protected by multiple US and International patents.
|
||||
#
|
||||
# This notice and attribution to Taligent may not be removed.
|
||||
# Taligent is a registered trademark of Taligent, Inc.
|
||||
|
||||
USD=$
|
|
@ -1,41 +0,0 @@
|
|||
# Copyright (c) 2005, 2012, 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. Oracle designates this
|
||||
# particular file as subject to the "Classpath" exception as provided
|
||||
# by Oracle in the LICENSE file that accompanied this code.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
|
||||
# (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved
|
||||
#
|
||||
# The original version of this source code and documentation
|
||||
# is copyrighted and owned by Taligent, Inc., a wholly-owned
|
||||
# subsidiary of IBM. These materials are provided under terms
|
||||
# of a License Agreement between Taligent and Sun. This technology
|
||||
# is protected by multiple US and International patents.
|
||||
#
|
||||
# This notice and attribution to Taligent may not be removed.
|
||||
# Taligent is a registered trademark of Taligent, Inc.
|
||||
|
||||
|
||||
# This bundle is empty because the data of the base bundle
|
||||
# is adequate for this locale.
|
||||
# The bundle is necessary to prevent the resource
|
||||
# bundle lookup from falling back to the default
|
||||
# locale.
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2012, 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
|
||||
* (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
|
||||
*
|
||||
* The original version of this source code and documentation
|
||||
* is copyrighted and owned by Taligent, Inc., a wholly-owned
|
||||
* subsidiary of IBM. These materials are provided under terms
|
||||
* of a License Agreement between Taligent and Sun. This technology
|
||||
* is protected by multiple US and International patents.
|
||||
*
|
||||
* This notice and attribution to Taligent may not be removed.
|
||||
* Taligent is a registered trademark of Taligent, Inc.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.util.resources;
|
||||
|
||||
import sun.util.resources.TimeZoneNamesBundle;
|
||||
|
||||
public final class TimeZoneNames_en extends TimeZoneNamesBundle {
|
||||
|
||||
// This bundle is empty because the root bundle's content
|
||||
// is adequate for this locale.
|
||||
// The bundle is necessary to prevent the resource
|
||||
// bundle lookup from falling back to the default
|
||||
// locale.
|
||||
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue