Skip to content

Commit

Permalink
CLDR-17407 Revert changes to beaufort, add hack to address deprecated…
Browse files Browse the repository at this point in the history
… timezone ids.
  • Loading branch information
macchiati committed Feb 26, 2024
1 parent e8ca95f commit aa8d282
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 31 deletions.
16 changes: 7 additions & 9 deletions common/supplemental/coverageLevels.xml
Original file line number Diff line number Diff line change
Expand Up @@ -939,14 +939,12 @@ For terms of use, see http://www.unicode.org/copyright.html
<coverageLevel inTerritory="%unitBeaufortRegions" value="modern" match="units/unitLength[@type='%unitLengths']/unit[@type='speed-beaufort']/displayName"/>
<coverageLevel inTerritory="%unitBeaufortRegions" value="modern" match="units/unitLength[@type='%unitLengths']/unit[@type='speed-beaufort']/gender"/>
<coverageLevel inTerritory="%unitBeaufortRegions" value="modern" match="units/unitLength[@type='%unitLengths']/unit[@type='speed-beaufort']/perUnitPattern"/>
<!-- Then make Beaufort explicitly comprehensive for other regions
This does not appear to be working.
<!-- Then make Beaufort explicitly comprehensive for other regions -->
<coverageLevel value="comprehensive" match="units/unitLength[@type='%unitLengths']/unit[@type='speed-beaufort']/unitPattern[@count='%anyAttribute'][@case='%anyAttribute']"/>
<coverageLevel value="comprehensive" match="units/unitLength[@type='%unitLengths']/unit[@type='speed-beaufort']/unitPattern[@count='%anyAttribute']"/>
<coverageLevel value="comprehensive" match="units/unitLength[@type='%unitLengths']/unit[@type='speed-beaufort']/displayName"/>
<coverageLevel value="comprehensive" match="units/unitLength[@type='%unitLengths']/unit[@type='speed-beaufort']/gender"/>
<coverageLevel value="comprehensive" match="units/unitLength[@type='%unitLengths']/unit[@type='speed-beaufort']/perUnitPattern"/>
-->
<!-- Then handle other units -->

<coverageLevel inLanguage="en" value="modern" match="units/unitLength[@type='%unitLengths']/unit[@type='%unitsEnglish']/unitPattern[@count='%anyAttribute']"/>
Expand All @@ -958,13 +956,13 @@ For terms of use, see http://www.unicode.org/copyright.html
<coverageLevel value="modern" match="units/unitLength[@type='%unitLengths']/compoundUnit[@type='%anyAttribute']/compoundUnitPattern1[@count='%anyAttribute'][@gender='%anyAttribute']"/>
<coverageLevel value="modern" match="units/unitLength[@type='%unitLengths']/compoundUnit[@type='%anyAttribute']/compoundUnitPattern1[@count='%anyAttribute'][@case='%anyAttribute']"/>
<coverageLevel value="modern" match="units/unitLength[@type='%unitLengths']/compoundUnit[@type='%anyAttribute']/compoundUnitPattern1[@count='%anyAttribute']"/>
<coverageLevel value="modern" match="units/unitLength[@type='%unitLengths']/compoundUnit[@type='%anyAttribute']/unitPrefixPattern"/>

<coverageLevel value="modern" match="units/unitLength[@type='%unitLengths']/unit[@type='(?!speed-beaufort)%anyAttribute']/unitPattern[@count='%anyAttribute'][@case='%anyAttribute']"/>
<coverageLevel value="modern" match="units/unitLength[@type='%unitLengths']/unit[@type='(?!speed-beaufort)%anyAttribute']/unitPattern[@count='%anyAttribute']"/>
<coverageLevel value="modern" match="units/unitLength[@type='%unitLengths']/unit[@type='(?!speed-beaufort)%anyAttribute']/displayName"/>
<coverageLevel value="modern" match="units/unitLength[@type='%unitLengths']/unit[@type='(?!speed-beaufort)%anyAttribute']/gender"/>
<coverageLevel value="modern" match="units/unitLength[@type='%unitLengths']/unit[@type='(?!speed-beaufort)%anyAttribute']/perUnitPattern"/>
<coverageLevel value="modern" match="units/unitLength[@type='%unitLengths']/unit[@type='%anyAttribute']/unitPattern[@count='%anyAttribute'][@case='%anyAttribute']"/>
<coverageLevel value="modern" match="units/unitLength[@type='%unitLengths']/unit[@type='%anyAttribute']/unitPattern[@count='%anyAttribute']"/>
<coverageLevel value="modern" match="units/unitLength[@type='%unitLengths']/unit[@type='%anyAttribute']/displayName"/>
<coverageLevel value="modern" match="units/unitLength[@type='%unitLengths']/unit[@type='%anyAttribute']/gender"/>
<coverageLevel value="modern" match="units/unitLength[@type='%unitLengths']/unit[@type='%anyAttribute']/perUnitPattern"/>
<coverageLevel value="modern" match="units/unitLength[@type='%unitLengths']/compoundUnit[@type='%anyAttribute']/unitPrefixPattern"/>

<coverageLevel value="modern" match="localeDisplayNames/types/type[@key='calendar'][@type='%calendarType80']"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import com.google.common.collect.TreeMultimap;
import com.ibm.icu.impl.IterableComparator;
import com.ibm.icu.impl.Relation;
Expand Down Expand Up @@ -5244,28 +5245,58 @@ public Set<String> getUnitPrefixes() {
return unitPrefixInfo.keySet();
}

/**
* Filter out deprecated items. This is more complicated than it seems. The deprecation is in
* timezones.xml, eg: <type name="cathu" description="Thunder Bay, Canada" deprecated="true"
* preferred="cator"/> <type name="cator" description="Toronto, Canada" alias="America/Toronto
* America/Montreal Canada/Eastern America/Nipigon America/Thunder_Bay"/> We need to find the
* short id's that are deprecated, put there is a problem due to
* https://unicode-org.atlassian.net/browse/CLDR-17412.
*
* <p>America/Nipigon, America/Thunder_Bay, America/Rainy_River
*/
Supplier<Set<String>> goodTimezones =
Suppliers.memoize(
new Supplier<Set<String>>() {

@Override
public Set<String> get() {
Set<String> availableLongTz = sc.getAvailableCodes(CodeType.tzid);
Map<String, String> aliasToRegular = bcp47KeyToAliasToSubtype.get("tz");
Map<String, Bcp47KeyInfo> subtypeToInfo =
bcp47KeyToSubtypeToInfo.get("tz");
Set<String> result =
availableLongTz.stream()
.filter(
x -> {
String shortId = aliasToRegular.get(x);
Bcp47KeyInfo info =
subtypeToInfo.get(shortId);
if (info.deprecated) {
System.out.println("deprecated: " + x);
}
return info.deprecated;
})
.collect(Collectors.toUnmodifiableSet());
Set<String> result = null;
if (true) { // hack for now
final Set<String> hack =
Set.of(
"America/Santa_Isabel",
"Australia/Currie",
"America/Yellowknife",
"America/Rainy_River",
"America/Thunder_Bay",
"America/Nipigon",
"America/Pangnirtung",
"Europe/Uzhgorod",
"Europe/Zaporozhye",
"Pacific/Johnston");
result = Set.copyOf(Sets.difference(availableLongTz, hack));
} else { // TODO restore when CLDR-17412 is fixed
Map<String, String> aliasToRegular =
bcp47KeyToAliasToSubtype.get("tz");
Map<String, Bcp47KeyInfo> subtypeToInfo =
bcp47KeyToSubtypeToInfo.get("tz");
result =
availableLongTz.stream()
.filter(
x -> {
String shortId = aliasToRegular.get(x);
Bcp47KeyInfo info =
subtypeToInfo.get(shortId);
System.out.println(
String.format(
"%s %s %s",
x, shortId, info));
return !info.deprecated;
})
.collect(Collectors.toUnmodifiableSet());
}
return result;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -840,14 +840,12 @@ public void TestFallbackFormat() {

public void Test4897() {
ExampleGenerator exampleGenerator = getExampleGenerator("it");
final CLDRFile cldrFile = exampleGenerator.getCldrFile();
for (String xpath :
With.in(
exampleGenerator
.getCldrFile()
.iterator(
"//ldml/dates/timeZoneNames",
exampleGenerator.getCldrFile().getComparator()))) {
String value = exampleGenerator.getCldrFile().getStringValue(xpath);
cldrFile.iterator(
"//ldml/dates/timeZoneNames", cldrFile.getComparator()))) {
String value = cldrFile.getStringValue(xpath);
String actual = exampleGenerator.getExampleHtml(xpath, value);
if (actual == null) {
if (!xpath.contains("singleCountries") && !xpath.contains("gmtZeroFormat")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Set;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -38,6 +39,7 @@ void testTargetCoverageLevel(final String locale, final String level) {
void testTimezoneExclusions() {
SupplementalDataInfo sdi = SupplementalDataInfo.getInstance();
Set<String> timezones = sdi.getCLDRTimezoneCodes();
assertTrue(timezones.contains("Europe/Andorra"));
assertFalse(timezones.contains("America/Nipigon"));
}
}

0 comments on commit aa8d282

Please sign in to comment.