[Unicode]   Common Locale Data Repository : Bug Tracking Home | Site Map | Search
 

Changeset 11567


Ignore:
Timestamp:
04/25/15 13:08:00 (4 years ago)
Author:
mdavis
Message:

cldrbug 5390: better fix for decimals. Still not perfect, since that awaits a separate bug fix. But good enough (I think)

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/cldr-unittest/src/org/unicode/cldr/unittest/TestExampleGenerator.java

    r11566 r11567  
    524524 
    525525    public void TestCompactPlurals() { 
    526         checkCompactExampleFor("de", Count.one, "〖❬1❭ Mio. €〗", "short", "currency"); 
    527         checkCompactExampleFor("de", Count.other, "〖❬2❭ Mio. €〗", "short", "currency"); 
    528         checkCompactExampleFor("cs", Count.many, "〖❬1,1❭ milionu〗", "long", "decimal"); 
    529         checkCompactExampleFor("pl", Count.other, "〖❬1,1❭ miliona〗", "long", "decimal"); 
     526        checkCompactExampleFor("de", Count.one, "〖❬1❭ Mio. €〗", "short", "currency", "000000"); 
     527        checkCompactExampleFor("de", Count.other, "〖❬2❭ Mio. €〗", "short", "currency", "000000"); 
     528        checkCompactExampleFor("de", Count.one, "〖❬12❭ Mio. €〗", "short", "currency", "0000000"); 
     529        checkCompactExampleFor("de", Count.other, "〖❬10❭ Mio. €〗", "short", "currency", "0000000"); 
     530        checkCompactExampleFor("cs", Count.many, "〖❬1,1❭ milionu〗", "long", "decimal", "000000"); 
     531        checkCompactExampleFor("pl", Count.other, "〖❬1,1❭ miliona〗", "long", "decimal", "000000"); 
    530532    } 
    531533 
    532534    private void checkCompactExampleFor(String localeID, Count many, 
    533         String expected, String longVsShort, String decimalVsCurrency) { 
     535        String expected, String longVsShort, String decimalVsCurrency, String zeros) { 
    534536        CLDRFile cldrFile = info.getCldrFactory().make(localeID, true); 
    535537        ExampleGenerator exampleGenerator = new ExampleGenerator(cldrFile, 
     
    539541            + "/" + decimalVsCurrency + "FormatLength[@type=\"" + longVsShort + "\"]" 
    540542            + "/" + decimalVsCurrency + "Format[@type=\"standard\"]" 
    541             + "/pattern[@type=\"1000000\"][@count=\"" + many + "\"]"; 
     543            + "/pattern[@type=\"1" + zeros + "\"][@count=\"" + many + "\"]"; 
    542544        checkPathValue(exampleGenerator, path, cldrFile.getStringValue(path), 
    543545            expected); 
  • trunk/tools/java/org/unicode/cldr/test/ExampleGenerator.java

    r11566 r11567  
    11631163        DecimalFormat df = icuServiceBuilder.getCurrencyFormat(currency, currencySymbol, numberSystem); 
    11641164        df.applyPattern(value); 
    1165          
     1165 
    11661166        String countValue = parts.getAttributeValue(-1, "count"); 
    11671167        if (countValue != null) { 
     
    12231223        Double numberSample = getExampleForPattern(numberFormat, count); 
    12241224        if (numberSample == null) { 
     1225            // Ideally, we would suppress the value in the survey tool. 
     1226            // However, until we switch over to the ICU samples, we are not guaranteed 
     1227            // that "no samples" means "can't occur". So we manufacture something. 
    12251228            int digits = numberFormat.getMinimumIntegerDigits(); 
    1226             return formatNumber(numberFormat, 1.2345678 * Math.pow(10, digits - 1)); 
    1227         } else { 
    1228             String temp = String.valueOf(numberSample); 
    1229             int fractionLength = temp.endsWith(".0") ? 0 : temp.length() - temp.indexOf('.') - 1; 
    1230             if (fractionLength != numberFormat.getMaximumFractionDigits()) { 
    1231                 numberFormat = (DecimalFormat) numberFormat.clone(); // for safety 
    1232                 numberFormat.setMinimumFractionDigits(fractionLength); 
    1233                 numberFormat.setMaximumFractionDigits(fractionLength); 
    1234             } 
    1235             return formatNumber(numberFormat, numberSample); 
    1236         } 
     1229            numberSample = (double) Math.round(1.2345678901234 * Math.pow(10, digits - 1)); 
     1230        } 
     1231        String temp = String.valueOf(numberSample); 
     1232        int fractionLength = temp.endsWith(".0") ? 0 : temp.length() - temp.indexOf('.') - 1; 
     1233        if (fractionLength != numberFormat.getMaximumFractionDigits()) { 
     1234            numberFormat = (DecimalFormat) numberFormat.clone(); // for safety 
     1235            numberFormat.setMinimumFractionDigits(fractionLength); 
     1236            numberFormat.setMaximumFractionDigits(fractionLength); 
     1237        } 
     1238        return formatNumber(numberFormat, numberSample); 
    12371239    } 
    12381240 
Note: See TracChangeset for help on using the changeset viewer.