ICU-8611 Allow number patterns to be looked up by numbering system

X-SVN-Rev: 30576
This commit is contained in:
John Emmons 2011-08-24 22:33:08 +00:00
parent bda69e7101
commit d3f81bfa50

View File

@ -22,6 +22,7 @@ import java.util.MissingResourceException;
import java.util.Set;
import com.ibm.icu.impl.ICUResourceBundle;
import com.ibm.icu.text.NumberingSystem;
import com.ibm.icu.util.Currency;
import com.ibm.icu.util.CurrencyAmount;
import com.ibm.icu.util.ULocale;
@ -1425,12 +1426,16 @@ public abstract class NumberFormat extends UFormat {
ICUResourceBundle rb = (ICUResourceBundle)UResourceBundle.
getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, forLocale);
String[] numberPatternKeys = { "decimalFormat", "currencyFormat", "percentFormat", "scientificFormat" };
return rb.getStringWithFallback("NumberElements/latn/patterns/"+numberPatternKeys[entry]);
//
// TODO: Make lookups of patterns depend on the locale's numbering system.
// Right now we assume "latn" because no locales have any variations this way.
// But we have the structure in CLDR to do this.
//
NumberingSystem ns = NumberingSystem.getInstance(forLocale);
String result = null;
try {
result = rb.getStringWithFallback("NumberElements/" + ns.getName() + "/patterns/"+numberPatternKeys[entry]);
} catch ( MissingResourceException ex ) {
result = rb.getStringWithFallback("NumberElements/latn/patterns/"+numberPatternKeys[entry]);
}
return result;
}
/**