Java Code Examples for com.ibm.icu.util.ULocale#createCanonical()
The following examples show how to use
com.ibm.icu.util.ULocale#createCanonical() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CalendarUtil.java From fitnotifications with Apache License 2.0 | 6 votes |
/** * Returns a calendar type for the given locale. * When the given locale has calendar keyword, the * value of calendar keyword is returned. Otherwise, * the default calendar type for the locale is returned. * @param loc The locale * @return Calendar type string, such as "gregorian" */ public static String getCalendarType(ULocale loc) { String calType = loc.getKeywordValue(CALKEY); if (calType != null) { return calType; } // Canonicalize, so grandfathered variant will be transformed to keywords ULocale canonical = ULocale.createCanonical(loc.toString()); calType = canonical.getKeywordValue(CALKEY); if (calType != null) { return calType; } // When calendar keyword is not available, use the locale's // region to get the default calendar type String region = ULocale.getRegionForSupplementalData(canonical, true); return CalendarPreferences.INSTANCE.getCalendarTypeForRegion(region); }
Example 2
Source File: PluralRulesLoader.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * Returns the locales for which we have plurals data. Utility for testing. */ public ULocale[] getAvailableULocales() { Set<String> keys = getLocaleIdToRulesIdMap(PluralType.CARDINAL).keySet(); ULocale[] locales = new ULocale[keys.size()]; int n = 0; for (Iterator<String> iter = keys.iterator(); iter.hasNext();) { locales[n++] = ULocale.createCanonical(iter.next()); } return locales; }