Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLDR-17459 Fixups for printing list, prefixable #3688

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1922,8 +1922,9 @@ public Set<UnitSystem> getSystemsEnum(String unit) {
main:
for (Map<String, Integer> unitsToPowers :
Arrays.asList(id.denUnitsToPowers, id.numUnitsToPowers)) {
for (String subunit : unitsToPowers.keySet()) {
subunit = UnitConverter.stripPrefix(subunit, null);
for (String rawSubunit : unitsToPowers.keySet()) {
String subunit = UnitConverter.stripPrefix(rawSubunit, null);

Set<UnitSystem> systems = new TreeSet<>(sourceToSystems.get(subunit));
if (systems.contains(UnitSystem.metric)) {
systems.add(UnitSystem.metric_adjacent);
Expand All @@ -1934,8 +1935,12 @@ public Set<UnitSystem> getSystemsEnum(String unit) {

if (result == null) {
result = systems; // first setting
if (!subunit.equals(rawSubunit)) {
result.remove(UnitSystem.prefixable);
}
} else {
result.retainAll(systems);
result.remove(UnitSystem.prefixable); // remove if more than one
}
if (result.isEmpty()) {
break main;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.ibm.icu.impl.Row.R3;
import com.ibm.icu.number.FormattedNumber;
import com.ibm.icu.number.LocalizedNumberFormatter;
import com.ibm.icu.number.Notation;
import com.ibm.icu.number.NumberFormatter;
import com.ibm.icu.number.NumberFormatter.UnitWidth;
import com.ibm.icu.number.Precision;
Expand Down Expand Up @@ -3544,7 +3545,7 @@ enum TranslationStatus {
has_grammar_X,
add_grammar,
skip_grammar,
skip_trans("\t— specific langs poss.)");
skip_trans("\tspecific langs poss.");

private TranslationStatus() {
outName = name();
Expand Down Expand Up @@ -3599,8 +3600,22 @@ public void TestUnitsToTranslate() {
: TranslationStatus.skip_grammar;
shortUnitToTranslationStatus40.put(shortUnit, status);
}
LocalizedNumberFormatter nf =
NumberFormatter.with()
.notation(Notation.scientific())
.precision(Precision.fixedSignificantDigits(7))
.locale(Locale.ENGLISH);
Output<String> base = new Output<>();
for (Entry<String, TranslationStatus> entry : shortUnitToTranslationStatus40.entrySet()) {
String shortUnit = entry.getKey();
var conversionInfo = converter.parseUnitId(shortUnit, base, false);
String factor =
conversionInfo == null || conversionInfo.special != null
? "n/a"
: nf.format(conversionInfo.factor.doubleValue())
.toString()
.replace("E", " × 10^");

TranslationStatus status40 = entry.getValue();
if (isVerbose())
System.out.println(
Expand All @@ -3610,6 +3625,8 @@ public void TestUnitsToTranslate() {
+ "\t"
+ converter.getSystemsEnum(shortUnit)
+ "\t"
+ factor
+ "\t"
+ (converter.isSimple(shortUnit) ? "simple" : "complex")
+ "\t"
+ status40);
Expand Down
Loading