mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-10136 Do not throw an exception when requesting the quotes for fr_CA. It should fallback to data from fr.
X-SVN-Rev: 33568
This commit is contained in:
parent
707a8976f4
commit
c55b3819a6
2 changed files with 21 additions and 6 deletions
|
@ -247,6 +247,13 @@ public final class LocaleData {
|
|||
return noSubstitute;
|
||||
}
|
||||
|
||||
private static final String [] DELIMITER_TYPES = {
|
||||
"quotationStart",
|
||||
"quotationEnd",
|
||||
"alternateQuotationStart",
|
||||
"alternateQuotationEnd"
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves a delimiter string from the locale data.
|
||||
*
|
||||
|
@ -257,12 +264,9 @@ public final class LocaleData {
|
|||
* @stable ICU 3.4
|
||||
*/
|
||||
public String getDelimiter(int type) {
|
||||
String [] delimiterTypes = { "quotationStart",
|
||||
"quotationEnd",
|
||||
"alternateQuotationStart",
|
||||
"alternateQuotationEnd" };
|
||||
|
||||
ICUResourceBundle stringBundle = (ICUResourceBundle) bundle.get("delimiters").get(delimiterTypes[type]);
|
||||
ICUResourceBundle delimitersBundle = (ICUResourceBundle) bundle.get("delimiters");
|
||||
// Only some of the quotation marks may be here. So we make sure that we do a multilevel fallback.
|
||||
ICUResourceBundle stringBundle = delimitersBundle.getWithFallback(DELIMITER_TYPES[type]);
|
||||
|
||||
if ( noSubstitute && (stringBundle.getLoadingStatus() == ICUResourceBundle.FROM_ROOT) )
|
||||
return null;
|
||||
|
|
|
@ -355,6 +355,17 @@ public class LocaleDataTest extends TestFmwk{
|
|||
logln(ld.getDelimiter(LocaleData.ALT_QUOTATION_END));
|
||||
}
|
||||
|
||||
public void TestFallback(){
|
||||
LocaleData fr_FR = LocaleData.getInstance(ULocale.FRANCE);
|
||||
LocaleData fr_CA = LocaleData.getInstance(ULocale.CANADA_FRENCH);
|
||||
|
||||
// This better not crash when only some values are overridden
|
||||
assertEquals("Start quotes are not equal", fr_FR.getDelimiter(LocaleData.QUOTATION_START), fr_CA.getDelimiter(LocaleData.QUOTATION_START));
|
||||
assertEquals("End quotes are not equals", fr_FR.getDelimiter(LocaleData.QUOTATION_END), fr_CA.getDelimiter(LocaleData.QUOTATION_END));
|
||||
assertNotEquals("Alt start quotes are equal", fr_FR.getDelimiter(LocaleData.ALT_QUOTATION_START), fr_CA.getDelimiter(LocaleData.ALT_QUOTATION_START));
|
||||
assertNotEquals("Alt end quotes are equals", fr_FR.getDelimiter(LocaleData.ALT_QUOTATION_END), fr_CA.getDelimiter(LocaleData.ALT_QUOTATION_END));
|
||||
}
|
||||
|
||||
public void TestLocaleDisplayPattern(){
|
||||
LocaleData ld = LocaleData.getInstance();
|
||||
logln("Default locale "+ " LocaleDisplayPattern:" + ld.getLocaleDisplayPattern());
|
||||
|
|
Loading…
Add table
Reference in a new issue