8306031: Update IANA Language Subtag Registry to Version 2023-04-13
Reviewed-by: naoto
This commit is contained in:
parent
88d9ebf8e8
commit
00b1eacad6
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -39,7 +39,7 @@ import java.util.Locale;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.stream.Collectors;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This tool reads the IANA Language Subtag Registry data file downloaded from
|
* This tool reads the IANA Language Subtag Registry data file downloaded from
|
||||||
@ -136,10 +136,29 @@ public class EquivMapsGenerator {
|
|||||||
}
|
}
|
||||||
} else { // language, extlang, legacy, and redundant
|
} else { // language, extlang, legacy, and redundant
|
||||||
if (!initialLanguageMap.containsKey(preferred)) {
|
if (!initialLanguageMap.containsKey(preferred)) {
|
||||||
sb = new StringBuilder(preferred);
|
// IANA update 4/13 introduced case where a preferred value
|
||||||
sb.append(',');
|
// can have a preferred value itself.
|
||||||
sb.append(tag);
|
// eg: ar-ajp has pref ajp which has pref apc
|
||||||
initialLanguageMap.put(preferred, sb);
|
boolean foundInOther = false;
|
||||||
|
Pattern pattern = Pattern.compile(","+preferred+"(,|$)");
|
||||||
|
// Check if current pref exists inside a value for another pref
|
||||||
|
List<StringBuilder> doublePrefs = initialLanguageMap
|
||||||
|
.values()
|
||||||
|
.stream()
|
||||||
|
.filter(e -> pattern.matcher(e.toString()).find())
|
||||||
|
.toList();
|
||||||
|
for (StringBuilder otherPrefVal : doublePrefs) {
|
||||||
|
otherPrefVal.append(",");
|
||||||
|
otherPrefVal.append(tag);
|
||||||
|
foundInOther = true;
|
||||||
|
}
|
||||||
|
if (!foundInOther) {
|
||||||
|
// does not exist in any other pref's values, so add as new entry
|
||||||
|
sb = new StringBuilder(preferred);
|
||||||
|
sb.append(',');
|
||||||
|
sb.append(tag);
|
||||||
|
initialLanguageMap.put(preferred, sb);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sb = initialLanguageMap.get(preferred);
|
sb = initialLanguageMap.get(preferred);
|
||||||
sb.append(',');
|
sb.append(',');
|
||||||
@ -156,7 +175,7 @@ public class EquivMapsGenerator {
|
|||||||
// "yue" is defined both as extlang and redundant. Remove the dup.
|
// "yue" is defined both as extlang and redundant. Remove the dup.
|
||||||
subtags = Arrays.stream(initialLanguageMap.get(preferred).toString().split(","))
|
subtags = Arrays.stream(initialLanguageMap.get(preferred).toString().split(","))
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toList())
|
.toList()
|
||||||
.toArray(new String[0]);
|
.toArray(new String[0]);
|
||||||
|
|
||||||
if (subtags.length == 2) {
|
if (subtags.length == 2) {
|
||||||
@ -241,7 +260,7 @@ public class EquivMapsGenerator {
|
|||||||
+ " static final Map<String, String[]> multiEquivsMap;\n"
|
+ " static final Map<String, String[]> multiEquivsMap;\n"
|
||||||
+ " static final Map<String, String> regionVariantEquivMap;\n\n"
|
+ " static final Map<String, String> regionVariantEquivMap;\n\n"
|
||||||
+ " static {\n"
|
+ " static {\n"
|
||||||
+ " singleEquivMap = new HashMap<>(";
|
+ " singleEquivMap = HashMap.newHashMap(";
|
||||||
|
|
||||||
private static final String footerText =
|
private static final String footerText =
|
||||||
" }\n\n"
|
" }\n\n"
|
||||||
@ -263,11 +282,11 @@ public class EquivMapsGenerator {
|
|||||||
Paths.get(fileName))) {
|
Paths.get(fileName))) {
|
||||||
writer.write(getOpenJDKCopyright());
|
writer.write(getOpenJDKCopyright());
|
||||||
writer.write(headerText
|
writer.write(headerText
|
||||||
+ (int)(sortedLanguageMap1.size() / 0.75f + 1) + ");\n"
|
+ sortedLanguageMap1.size() + ");\n"
|
||||||
+ " multiEquivsMap = new HashMap<>("
|
+ " multiEquivsMap = HashMap.newHashMap("
|
||||||
+ (int)(sortedLanguageMap2.size() / 0.75f + 1) + ");\n"
|
+ sortedLanguageMap2.size() + ");\n"
|
||||||
+ " regionVariantEquivMap = new HashMap<>("
|
+ " regionVariantEquivMap = HashMap.newHashMap("
|
||||||
+ (int)(sortedRegionVariantMap.size() / 0.75f + 1) + ");\n\n"
|
+ sortedRegionVariantMap.size() + ");\n\n"
|
||||||
+ " // This is an auto-generated file and should not be manually edited.\n"
|
+ " // This is an auto-generated file and should not be manually edited.\n"
|
||||||
+ " // LSR Revision: " + LSRrevisionDate);
|
+ " // LSR Revision: " + LSRrevisionDate);
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
File-Date: 2023-03-22
|
File-Date: 2023-04-13
|
||||||
%%
|
%%
|
||||||
Type: language
|
Type: language
|
||||||
Subtag: aa
|
Subtag: aa
|
||||||
@ -42986,7 +42986,7 @@ Subtag: ajp
|
|||||||
Description: South Levantine Arabic
|
Description: South Levantine Arabic
|
||||||
Added: 2009-07-29
|
Added: 2009-07-29
|
||||||
Deprecated: 2023-03-17
|
Deprecated: 2023-03-17
|
||||||
Preferred-Value: apc
|
Preferred-Value: ajp
|
||||||
Prefix: ar
|
Prefix: ar
|
||||||
Macrolanguage: ar
|
Macrolanguage: ar
|
||||||
%%
|
%%
|
||||||
|
@ -24,9 +24,9 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8040211 8191404 8203872 8222980 8225435 8241082 8242010 8247432
|
* @bug 8040211 8191404 8203872 8222980 8225435 8241082 8242010 8247432
|
||||||
* 8258795 8267038 8287180 8302512 8304761
|
* 8258795 8267038 8287180 8302512 8304761 8306031
|
||||||
* @summary Checks the IANA language subtag registry data update
|
* @summary Checks the IANA language subtag registry data update
|
||||||
* (LSR Revision: 2023-03-22) with Locale and Locale.LanguageRange
|
* (LSR Revision: 2023-04-13) with Locale and Locale.LanguageRange
|
||||||
* class methods.
|
* class methods.
|
||||||
* @run main LanguageSubtagRegistryTest
|
* @run main LanguageSubtagRegistryTest
|
||||||
*/
|
*/
|
||||||
@ -44,7 +44,7 @@ public class LanguageSubtagRegistryTest {
|
|||||||
static boolean err = false;
|
static boolean err = false;
|
||||||
|
|
||||||
private static final String ACCEPT_LANGUAGE =
|
private static final String ACCEPT_LANGUAGE =
|
||||||
"Accept-Language: aam, adp, aeb, ajs, aog, apc, aue, bcg, bic, bpp, cey, cbr, cnp, cqu, crr, csp, csx, dif, dmw, dsz, ehs, ema,"
|
"Accept-Language: aam, adp, aeb, ajs, aog, apc, ajp, aue, bcg, bic, bpp, cey, cbr, cnp, cqu, crr, csp, csx, dif, dmw, dsz, ehs, ema,"
|
||||||
+ " en-gb-oed, gti, iba, jks, kdz, kjh, kmb, koj, kru, ksp, kwq, kxe, kzk, lgs, lii, lmm, lsb, lsc, lsn, lsv, lsw, lvi, mtm,"
|
+ " en-gb-oed, gti, iba, jks, kdz, kjh, kmb, koj, kru, ksp, kwq, kxe, kzk, lgs, lii, lmm, lsb, lsc, lsn, lsv, lsw, lvi, mtm,"
|
||||||
+ " ngv, nns, ola, oyb, pat, phr, plu, pnd, pub, rib, rnb, rsn, scv, snz, sqx, suj, szy, taj, tdg, tjj, tjp, tpn, tvx,"
|
+ " ngv, nns, ola, oyb, pat, phr, plu, pnd, pub, rib, rnb, rsn, scv, snz, sqx, suj, szy, taj, tdg, tjj, tjp, tpn, tvx,"
|
||||||
+ " umi, uss, uth, ysm, zko, wkr;q=0.9, ar-hyw;q=0.8, yug;q=0.5, gfx;q=0.4";
|
+ " umi, uss, uth, ysm, zko, wkr;q=0.9, ar-hyw;q=0.8, yug;q=0.5, gfx;q=0.4";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user