import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
+import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.MissingResourceException;
ICUResourceBundle rb = (ICUResourceBundle) UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME,currentLocale);
ICUResourceBundle calBundle = rb.getWithFallback("calendar");
ICUResourceBundle calTypeBundle = calBundle.getWithFallback(calendarTypeToUse);
+ // Start hack to force inheriting sideways from generic before up to parent locale.
+ // This happens in ICU4C just via the aliases in root, not sure why not here.
+ // This is added per #9952, #9964 for better long-term fix.
+ if (calTypeBundle != null && !calendarTypeToUse.equals("gregorian") && !calendarTypeToUse.equals("chinese")) {
+ Locale desiredLocale = rb.getLocale();
+ Locale calDataLocale = calTypeBundle.getLocale();
+ if (!calDataLocale.equals(desiredLocale)) {
+ calTypeBundle = calBundle.getWithFallback("generic");
+ }
+ }
+ // End hack
ICUResourceBundle itvDtPtnResource =calTypeBundle.getWithFallback("intervalFormats");
// look for fallback first, since it establishes the default order
String fallback = itvDtPtnResource.getStringWithFallback(FALLBACK_STRING);
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.Set;
// Get data for that calendar
ICUResourceBundle calBundle = rb.getWithFallback("calendar");
ICUResourceBundle calTypeBundle = calBundle.getWithFallback(calendarTypeToUse);
+ // Start hack to force inheriting sideways from generic before up to parent locale.
+ // This happens in ICU4C just via the aliases in root, not sure why not here.
+ // This is added per #9952, #9964 for better long-term fix. Part 2 is below.
+ if (calTypeBundle != null && !calendarTypeToUse.equals("gregorian") && !calendarTypeToUse.equals("chinese")) {
+ Locale desiredLocale = rb.getLocale();
+ Locale calDataLocale = calTypeBundle.getLocale();
+ if (!calDataLocale.equals(desiredLocale)) {
+ calTypeBundle = calBundle.getWithFallback("generic");
+ }
+ }
+ // End hack
+
// CLDR item formats
if (pbundle == null) {
break;
}
+ calBundle = pbundle.getWithFallback("calendar");
+ calTypeBundle = calBundle.getWithFallback(calendarTypeToUse);
+ // Start hack for sideways inheritance, part 2
+ // This is added per #9952, #9964 for better long-term fix.
+ if (calTypeBundle != null && !calendarTypeToUse.equals("gregorian") && !calendarTypeToUse.equals("chinese")) {
+ Locale desiredLocale = pbundle.getLocale();
+ Locale calDataLocale = calTypeBundle.getLocale();
+ if (!calDataLocale.equals(desiredLocale)) {
+ calTypeBundle = calBundle.getWithFallback("generic");
+ }
+ }
+ // End hack part 2
try {
- availFormatsBundle = pbundle.getWithFallback("calendar/" + calendarTypeToUse + "/availableFormats");
+ availFormatsBundle = calTypeBundle.getWithFallback("availableFormats");
} catch (MissingResourceException e) {
availFormatsBundle = null;
}
for (int i = 0; i < TYPE_LIMIT; ++i) {
if (original[i].length() != 0) {
// append a string of the same length using the canonical character
- for (int j = 0; j < types.length; ++j) {
- int[] row = types[j];
- if (row[1] == i) {
- char originalChar = original[i].charAt(0);
- char repeatChar = (originalChar=='h' || originalChar=='K')? 'h': (char)row[0];
- result.append(Utility.repeat(String.valueOf(repeatChar), original[i].length()));
- break;
- }
- }
+ for (int j = 0; j < types.length; ++j) {
+ int[] row = types[j];
+ if (row[1] == i) {
+ char originalChar = original[i].charAt(0);
+ char repeatChar = (originalChar=='h' || originalChar=='K')? 'h': (char)row[0];
+ result.append(Utility.repeat(String.valueOf(repeatChar), original[i].length()));
+ break;
+ }
+ }
}
}
return result.toString();