diff --git a/common/dtd/ldmlSupplemental.dtd b/common/dtd/ldmlSupplemental.dtd index 4142f90dc1e..109cc80cc20 100644 --- a/common/dtd/ldmlSupplemental.dtd +++ b/common/dtd/ldmlSupplemental.dtd @@ -5,7 +5,7 @@ SPDX-License-Identifier: Unicode-DFS-2016 CLDR data files are interpreted according to the LDML specification (http://unicode.org/reports/tr35/) --> - + @@ -388,6 +388,25 @@ CLDR data files are interpreted according to the LDML specification (http://unic + + + + + + + + + + + + + + + + + diff --git a/common/supplemental/units.xml b/common/supplemental/units.xml index 27a66a86164..7a723d37a13 100644 --- a/common/supplemental/units.xml +++ b/common/supplemental/units.xml @@ -15,6 +15,40 @@ For terms of use, see http://www.unicode.org/copyright.html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/util/SupplementalDataInfo.java b/tools/cldr-code/src/main/java/org/unicode/cldr/util/SupplementalDataInfo.java index e21d200c434..2e0314a0c0f 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/util/SupplementalDataInfo.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/util/SupplementalDataInfo.java @@ -131,6 +131,24 @@ public String toShortId() { } } + public class UnitPrefixInfo { + final String abbreviation; + final int base; + final int power; + + public UnitPrefixInfo(String abbreviation, int base, int power) { + this.abbreviation = abbreviation; + this.base = base; + this.power = power; + } + + @Override + public String toString() { + return String.format( + "%s\t%s", abbreviation, String.valueOf(base) + "^" + String.valueOf(power)); + } + } + /** Official status of languages */ public enum OfficialStatus { unknown("U", 1), @@ -977,6 +995,8 @@ public enum RBNFGroup { private Map unitIdComponentType = new TreeMap<>(); + private Map unitPrefixInfo = new TreeMap<>(); + public Map grammarLocaleToTargetToFeatureToValues = new TreeMap<>(); public Map localeToGrammarDerivation = new TreeMap<>(); @@ -1233,6 +1253,8 @@ private void makeStuffSafe() { unitIdComponentType = CldrUtility.protectCollection(unitIdComponentType); + unitPrefixInfo = CldrUtility.protectCollection(unitPrefixInfo); + timeData = CldrUtility.protectCollection(timeData); validityInfo = CldrUtility.protectCollection(validityInfo); @@ -1386,6 +1408,10 @@ public void handlePathValue(String path, String value) { if (handleUnitUnitIdComponents(parts)) { return; } + } else if (level1.equals("unitPrefixes")) { + if (handleUnitPrefix(parts)) { + return; + } } else if (level1.equals("unitConstants")) { if (handleUnitConstants(parts)) { return; @@ -1439,6 +1465,22 @@ public void handlePathValue(String path, String value) { } } + private boolean handleUnitPrefix(XPathParts parts) { + // + String power10 = parts.getAttributeValue(-1, "power10"); + String power2 = parts.getAttributeValue(-1, "power2"); + if ((power10 != null) == (power2 != null)) { + throw new IllegalArgumentException("Must have exactly one @power2 or @power10"); + } + unitPrefixInfo.put( + parts.getAttributeValue(-1, "type"), + new UnitPrefixInfo( + parts.getAttributeValue(-1, "symbol"), + power10 != null ? 10 : 2, + Integer.parseInt(power10 != null ? power10 : power2))); + return true; + } + private boolean handlePersonNamesDefaults(String value, XPathParts parts) { personNameOrder.putAll( Order.from(parts.getAttributeValue(-1, "order")), split_space.split(value)); @@ -5053,4 +5095,12 @@ public GrammarDerivation getGrammarDerivation(String locale) { public Multimap getPersonNameOrder() { return personNameOrder; } + + public UnitPrefixInfo getUnitPrefixInfo(String prefix) { + return unitPrefixInfo.get(prefix); + } + + public Set getUnitPrefixes() { + return unitPrefixInfo.keySet(); + } } diff --git a/tools/cldr-code/src/main/resources/org/unicode/cldr/util/data/PathHeader.txt b/tools/cldr-code/src/main/resources/org/unicode/cldr/util/data/PathHeader.txt index 9bcfd32a3f7..7a742315cff 100644 --- a/tools/cldr-code/src/main/resources/org/unicode/cldr/util/data/PathHeader.txt +++ b/tools/cldr-code/src/main/resources/org/unicode/cldr/util/data/PathHeader.txt @@ -524,6 +524,9 @@ //supplementalData/unitIdComponents/unitIdComponent[@type="%A"]/_values ; Supplemental ; Units ; IdComponent ; $1-values ; HIDE +//supplementalData/unitPrefixes/unitPrefix[@type="%A"]/_symbol ; Supplemental ; Units ; Prefix ; $1-symbol ; HIDE +//supplementalData/unitPrefixes/unitPrefix[@type="%A"]/_power10 ; Supplemental ; Units ; Prefix ; $1-power10 ; HIDE +//supplementalData/unitPrefixes/unitPrefix[@type="%A"]/_power2 ; Supplemental ; Units ; Prefix ; $1-power2 ; HIDE //supplementalData/unitConstants/unitConstant[@constant="%A"]/_value ; Supplemental ; Units ; Constant ; $1-value ; HIDE //supplementalData/unitConstants/unitConstant[@constant="%A"]/_status ; Supplemental ; Units ; Constant ; $1-status ; HIDE //supplementalData/unitQuantities/unitQuantity[@baseUnit="%A"]/_quantity ; Supplemental ; Units ; Quantity ; $1-value ; HIDE