< prev index next >
make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java
Print this page
rev 57986 : 8234347: "Turkey" meta time zone does not generate composed localized names
8236548: Localized time zone name inconsistency between English and other locales
Reviewed-by:
*** 1,7 ****
/*
! * Copyright (c) 2012, 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. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2012, 2020, 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
*** 23,33 ****
* questions.
*/
package build.tools.cldrconverter;
- import static build.tools.cldrconverter.Bundle.jreTimeZoneNames;
import build.tools.cldrconverter.BundleGenerator.BundleType;
import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.*;
--- 23,32 ----
*** 87,97 ****
--- 86,98 ----
static final String TIMEZONE_ID_PREFIX = "timezone.id.";
static final String EXEMPLAR_CITY_PREFIX = "timezone.excity.";
static final String ZONE_NAME_PREFIX = "timezone.displayname.";
static final String METAZONE_ID_PREFIX = "metazone.id.";
static final String PARENT_LOCALE_PREFIX = "parentLocale.";
+ static final String META_EMPTY_ZONE_NAME = "EMPTY_ZONE";
static final String[] EMPTY_ZONE = {"", "", "", "", "", ""};
+ static final String META_ETCUTC_ZONE_NAME = "ETC_UTC";
private static SupplementDataParseHandler handlerSuppl;
private static LikelySubtagsParseHandler handlerLikelySubtags;
private static WinZonesParseHandler handlerWinZones;
static PluralsParseHandler handlerPlurals;
*** 684,755 ****
}
private static Map<String, Object> extractZoneNames(Map<String, Object> map, String id) {
Map<String, Object> names = new HashMap<>();
- // Copy over missing time zone ids from JRE for English locale
- if (id.equals("en")) {
- Map<String[], String> jreMetaMap = new HashMap<>();
- jreTimeZoneNames.stream().forEach(e -> {
- String tzid = (String)e[0];
- String[] data = (String[])e[1];
-
- if (map.get(TIMEZONE_ID_PREFIX + tzid) == null &&
- handlerMetaZones.get(tzid) == null ||
- handlerMetaZones.get(tzid) != null &&
- map.get(METAZONE_ID_PREFIX + handlerMetaZones.get(tzid)) == null) {
-
- // First, check the alias
- String canonID = canonicalTZMap.get(tzid);
- if (canonID != null && !tzid.equals(canonID)) {
- Object value = map.get(TIMEZONE_ID_PREFIX + canonID);
- if (value != null) {
- names.put(tzid, value);
- return;
- } else {
- String meta = handlerMetaZones.get(canonID);
- if (meta != null) {
- value = map.get(METAZONE_ID_PREFIX + meta);
- if (value != null) {
- names.put(tzid, meta);
- return;
- }
- }
- }
- }
-
- // Check the CLDR meta key
- Optional<Map.Entry<String, String>> cldrMeta =
- handlerMetaZones.getData().entrySet().stream()
- .filter(me ->
- Arrays.deepEquals(data,
- (String[])map.get(METAZONE_ID_PREFIX + me.getValue())))
- .findAny();
- cldrMeta.ifPresentOrElse(meta -> names.put(tzid, meta.getValue()), () -> {
- // Check the JRE meta key, add if there is not.
- Optional<Map.Entry<String[], String>> jreMeta =
- jreMetaMap.entrySet().stream()
- .filter(jm -> Arrays.deepEquals(data, jm.getKey()))
- .findAny();
- jreMeta.ifPresentOrElse(meta -> names.put(tzid, meta.getValue()), () -> {
- String metaName = "JRE_" + tzid.replaceAll("[/-]", "_");
- names.put(METAZONE_ID_PREFIX + metaName, data);
- names.put(tzid, metaName);
- });
- });
- }
- });
- }
-
getAvailableZoneIds().stream().forEach(tzid -> {
// If the tzid is deprecated, get the data for the replacement id
String tzKey = Optional.ofNullable((String)handlerSupplMeta.get(tzid))
.orElse(tzid);
Object data = map.get(TIMEZONE_ID_PREFIX + tzKey);
if (data instanceof String[]) {
names.put(tzid, data);
} else {
String meta = handlerMetaZones.get(tzKey);
if (meta != null) {
String metaKey = METAZONE_ID_PREFIX + meta;
data = map.get(metaKey);
--- 685,709 ----
}
private static Map<String, Object> extractZoneNames(Map<String, Object> map, String id) {
Map<String, Object> names = new HashMap<>();
getAvailableZoneIds().stream().forEach(tzid -> {
// If the tzid is deprecated, get the data for the replacement id
String tzKey = Optional.ofNullable((String)handlerSupplMeta.get(tzid))
.orElse(tzid);
Object data = map.get(TIMEZONE_ID_PREFIX + tzKey);
if (data instanceof String[]) {
+ // Hack for UTC. UTC is an alias to Etc/UTC in CLDR
+ if (tzid.equals("Etc/UTC") && !map.containsKey(TIMEZONE_ID_PREFIX + "UTC")) {
+ names.put(METAZONE_ID_PREFIX + META_ETCUTC_ZONE_NAME, data);
+ names.put(tzid, META_ETCUTC_ZONE_NAME);
+ names.put("UTC", META_ETCUTC_ZONE_NAME);
+ } else {
names.put(tzid, data);
+ }
} else {
String meta = handlerMetaZones.get(tzKey);
if (meta != null) {
String metaKey = METAZONE_ID_PREFIX + meta;
data = map.get(metaKey);
*** 763,789 ****
});
// exemplar cities.
Map<String, Object> exCities = map.entrySet().stream()
.filter(e -> e.getKey().startsWith(CLDRConverter.EXEMPLAR_CITY_PREFIX))
! .collect(Collectors
! .toMap(Map.Entry::getKey, Map.Entry::getValue));
names.putAll(exCities);
! if (!id.equals("en") &&
! !names.isEmpty()) {
! // CLDR does not have UTC entry, so add it here.
! names.put("UTC", EMPTY_ZONE);
!
! // no metazone zones
! Arrays.asList(handlerMetaZones.get(MetaZonesParseHandler.NO_METAZONE_KEY)
! .split("\\s")).stream()
! .forEach(tz -> {
! names.put(tz, EMPTY_ZONE);
! });
}
return names;
}
/**
* Extracts the language independent calendar data. Each of the two keys,
--- 717,742 ----
});
// exemplar cities.
Map<String, Object> exCities = map.entrySet().stream()
.filter(e -> e.getKey().startsWith(CLDRConverter.EXEMPLAR_CITY_PREFIX))
! .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
names.putAll(exCities);
! // If there's no UTC entry at this point, add an empty one
! if (!names.isEmpty() && !names.containsKey("UTC")) {
! names.putIfAbsent(METAZONE_ID_PREFIX + META_EMPTY_ZONE_NAME, EMPTY_ZONE);
! names.put("UTC", META_EMPTY_ZONE_NAME);
}
+ // Finally some compatibility stuff
+ ZoneId.SHORT_IDS.entrySet().stream()
+ .filter(e -> !names.containsKey(e.getKey()) && names.containsKey(e.getValue()))
+ .forEach(e -> {
+ names.put(e.getKey(), names.get(e.getValue()));
+ });
+
return names;
}
/**
* Extracts the language independent calendar data. Each of the two keys,
< prev index next >