Skip to content
Permalink
Browse files
8234347: "Turkey" meta time zone does not generate composed localized…
… names

8236548: Localized time zone name inconsistency between English and other locales

Reviewed-by: bae
Backport-of: 5c3a015
  • Loading branch information
Yuri Nesterenko committed Dec 7, 2020
1 parent 6456cad commit c4c63b919ef07d74af7341c2d5ef6e98de4d353c
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 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
@@ -40,7 +40,6 @@ $(eval $(call IncludeCustomExtension, CompileTools.gmk))
# Use += to be able to add to this from a custom extension
BUILD_TOOLS_SRC_DIRS += \
$(TOPDIR)/make/jdk/src/classes \
$(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes \
$(BUILDTOOLS_OUTPUTDIR)/interim_tzdb_classes \
#

This file was deleted.

@@ -75,9 +75,6 @@ interim-langtools:
interim-rmic:
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileInterimRmic.gmk)

interim-cldrconverter:
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CopyInterimCLDRConverter.gmk)

interim-tzdb:
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CopyInterimTZDB.gmk)

@@ -92,7 +89,7 @@ buildtools-hotspot:
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileToolsHotspot.gmk)

ALL_TARGETS += buildtools-langtools interim-langtools \
interim-rmic interim-cldrconverter interim-tzdb buildtools-jdk buildtools-modules \
interim-rmic interim-tzdb buildtools-jdk buildtools-modules \
buildtools-hotspot

################################################################################
@@ -671,7 +668,7 @@ else

interim-langtools: $(INTERIM_LANGTOOLS_GENSRC_TARGETS)

buildtools-jdk: interim-langtools interim-cldrconverter interim-tzdb
buildtools-jdk: interim-langtools interim-tzdb

buildtools-hotspot: interim-langtools

@@ -305,7 +305,6 @@ String getCurrencies() {
}

// First, weed out any empty timezone or metazone names from myMap.
// Fill in any missing abbreviations if locale is "en".
for (Iterator<String> it = myMap.keySet().iterator(); it.hasNext();) {
String key = it.next();
if (key.startsWith(CLDRConverter.TIMEZONE_ID_PREFIX)
@@ -318,10 +317,6 @@ String getCurrencies() {
it.remove();
continue;
}

if (id.equals("en")) {
fillInJREs(key, nameMap);
}
}
}
for (Iterator<String> it = myMap.keySet().iterator(); it.hasNext();) {
@@ -650,42 +645,6 @@ private String toMetaZoneKey(String tzKey) {
return null;
}

static List<Object[]> jreTimeZoneNames = Arrays.asList(TimeZoneNames.getContents());
private void fillInJREs(String key, Map<String, String> map) {
String tzid = null;

if (key.startsWith(CLDRConverter.METAZONE_ID_PREFIX)) {
// Look for tzid
String meta = key.substring(CLDRConverter.METAZONE_ID_PREFIX.length());
if (meta.equals("GMT")) {
tzid = meta;
} else {
for (String tz : CLDRConverter.handlerMetaZones.keySet()) {
if (CLDRConverter.handlerMetaZones.get(tz).equals(meta)) {
tzid = tz;
break;
}
}
}
} else {
tzid = key.substring(CLDRConverter.TIMEZONE_ID_PREFIX.length());
}

if (tzid != null) {
for (Object[] jreZone : jreTimeZoneNames) {
if (jreZone[0].equals(tzid)) {
for (int i = 0; i < ZONE_NAME_KEYS.length; i++) {
if (map.get(ZONE_NAME_KEYS[i]) == null) {
String[] jreNames = (String[])jreZone[1];
map.put(ZONE_NAME_KEYS[i], jreNames[i]);
}
}
break;
}
}
}
}

/**
* Perform a generic conversion of CLDR date-time format pattern letter based
* on the support given by the SimpleDateFormat and the j.t.f.DateTimeFormatter
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* 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
@@ -25,7 +25,6 @@

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;
@@ -88,7 +87,9 @@
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;
@@ -676,68 +677,21 @@ private boolean isDigit(char c) {
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);
// 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) {
@@ -754,24 +708,23 @@ private boolean isDigit(char c) {

// 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));
.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);
});
// 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;
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* 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
@@ -4237,9 +4237,15 @@ public int parse(DateTimeParseContext context, CharSequence text, int position)
char nextNextChar = text.charAt(position + 1);
if (context.charEquals(nextChar, 'U') && context.charEquals(nextNextChar, 'T')) {
if (length >= position + 3 && context.charEquals(text.charAt(position + 2), 'C')) {
return parseOffsetBased(context, text, position, position + 3, OffsetIdPrinterParser.INSTANCE_ID_ZERO);
// There are localized zone texts that start with "UTC", e.g.
// "UTC\u221210:00" (MINUS SIGN instead of HYPHEN-MINUS) in French.
// Exclude those ZoneText cases.
if (!(this instanceof ZoneTextPrinterParser)) {
return parseOffsetBased(context, text, position, position + 3, OffsetIdPrinterParser.INSTANCE_ID_ZERO);
}
} else {
return parseOffsetBased(context, text, position, position + 2, OffsetIdPrinterParser.INSTANCE_ID_ZERO);
}
return parseOffsetBased(context, text, position, position + 2, OffsetIdPrinterParser.INSTANCE_ID_ZERO);
} else if (context.charEquals(nextChar, 'G') && length >= position + 3 &&
context.charEquals(nextNextChar, 'M') && context.charEquals(text.charAt(position + 2), 'T')) {
if (length >= position + 4 && context.charEquals(text.charAt(position + 3), '0')) {
Loading

1 comment on commit c4c63b9

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on c4c63b9 Dec 7, 2020

Please sign in to comment.