}
}
}
}
ICUResourceBundle rb = (ICUResourceBundle) UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, uLocale);
ULocale parentLocale = rb.getULocale(); // for later
// Get the correct calendar type
String calendarTypeToUse = uLocale.getKeywordValue("calendar");
if ( calendarTypeToUse == null ) {
String[] preferredCalendarTypes = Calendar.getKeywordValuesForLocale("calendar", uLocale, true);
calendarTypeToUse = preferredCalendarTypes[0]; // the most preferred calendar
}
if ( calendarTypeToUse == null ) {
calendarTypeToUse = "gregorian"; // fallback
}
// Get data for that calendar
rb = rb.getWithFallback("calendar");
ICUResourceBundle calTypeBundle = rb.getWithFallback(calendarTypeToUse);
// CLDR item formats
// (hmm, do we need aliases in root for all non-gregorian calendars?)
try {
ICUResourceBundle itemBundle = calTypeBundle.getWithFallback("appendItems");
for (int i=0; i<itemBundle.getSize(); ++i) {
ICUResourceBundle formatBundle = (ICUResourceBundle)itemBundle.get(i);
String formatName = itemBundle.get(i).getKey();
String value = formatBundle.getString();
result.setAppendItemFormat(getAppendFormatNumber(formatName), value);
}
}catch(Exception e) {
}
// CLDR item names (hmm, do we need aliases in root for all non-gregorian calendars?)
try {
ICUResourceBundle itemBundle = calTypeBundle.getWithFallback("fields");
ICUResourceBundle fieldBundle, dnBundle;
for (int i=0; i<TYPE_LIMIT; ++i) {
if ( isCLDRFieldName(i) ) {
fieldBundle = itemBundle.getWithFallback(CLDR_FIELD_NAME[i]);
dnBundle = fieldBundle.getWithFallback("dn");
String value = dnBundle.getString();
//System.out.println("Field name:"+value);
result.setAppendItemName(i, value);
}
}
}catch(Exception e) {
}
// set the AvailableFormat in CLDR
try {
ICUResourceBundle formatBundle = calTypeBundle.getWithFallback("availableFormats");
//System.out.println("available format from current locale:"+uLocale.getName());
for (int i=0; i<formatBundle.getSize(); ++i) {
String formatKey = formatBundle.get(i).getKey();
String formatValue = formatBundle.get(i).getString();
//System.out.println(" availableFormat:"+formatValue);
result.setAvailableFormat(formatKey);
// Add pattern with its associated skeleton. Override any duplicate derived from std patterns,
// but not a previous availableFormats entry:
result.addPatternWithSkeleton(formatValue, formatKey, false, returnInfo);
}
}catch(Exception e) {
}
// ULocale parentLocale=uLocale; // now set up above with aliases resolved etc.
while ( (parentLocale=parentLocale.getFallback()) != null) {
ICUResourceBundle prb = (ICUResourceBundle) UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, parentLocale);
prb = prb.getWithFallback("calendar");
ICUResourceBundle pCalTypeBundle = prb.getWithFallback(calendarTypeToUse);
try {
ICUResourceBundle formatBundle = pCalTypeBundle.getWithFallback("availableFormats");
//System.out.println("available format from parent locale:"+parentLocale.getName());
for (int i=0; i<formatBundle.getSize(); ++i) {
String formatKey = formatBundle.get(i).getKey();
String formatValue = formatBundle.get(i).getString();
//System.out.println(" availableFormat:"+formatValue);
if (!result.isAvailableFormatSet(formatKey)) {
result.setAvailableFormat(formatKey);
// Add pattern with its associated skeleton. Override any duplicate derived from std patterns,
// but not a previous availableFormats entry: