com.ibm.icu.impl.ICUResourceBundle Java Examples
The following examples show how to use
com.ibm.icu.impl.ICUResourceBundle.
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: ULocale.java From trekarta with GNU General Public License v3.0 | 6 votes |
/** * Returns a list of all installed locales according to the specified type. * * @draft ICU 65 * @provisional This API might change or be removed in a future release. */ public static Collection<ULocale> getAvailableLocalesByType(AvailableType type) { if (type == null) { throw new IllegalArgumentException(); } List<ULocale> result; if (type == ULocale.AvailableType.WITH_LEGACY_ALIASES) { result = new ArrayList<>(); Collections.addAll(result, ICUResourceBundle.getAvailableULocales(ULocale.AvailableType.DEFAULT)); Collections.addAll(result, ICUResourceBundle.getAvailableULocales(ULocale.AvailableType.ONLY_LEGACY_ALIASES)); } else { result = Arrays.asList(ICUResourceBundle.getAvailableULocales(type)); } return Collections.unmodifiableList(result); }
Example #2
Source File: DateIntervalInfo.java From fitnotifications with Apache License 2.0 | 6 votes |
/** Processes the patterns for a skeleton table. */ public void processSkeletonTable(Key key, Value value) { // Iterate over all the patterns in the current skeleton table String currentSkeleton = key.toString(); UResource.Table patternData = value.getTable(); for (int k = 0; patternData.getKeyAndValue(k, key, value); k++) { if (value.getType() == ICUResourceBundle.STRING) { // Process the key CharSequence patternLetter = validateAndProcessPatternLetter(key); // If the calendar field has a valid value if (patternLetter != null) { // Get the largest different calendar unit String lrgDiffCalUnit = patternLetter.toString(); // Set the interval pattern setIntervalPatternIfAbsent(currentSkeleton, lrgDiffCalUnit, value); } } } }
Example #3
Source File: Currency.java From fitnotifications with Apache License 2.0 | 6 votes |
/** * Returns the ISO 4217 numeric code for this currency object. * <p>Note: If the ISO 4217 numeric code is not assigned for the currency or * the currency is unknown, this method returns 0.</p> * @return The ISO 4217 numeric code of this currency. * @stable ICU 49 */ public int getNumericCode() { int result = 0; try { UResourceBundle bundle = UResourceBundle.getBundleInstance( ICUData.ICU_BASE_NAME, "currencyNumericCodes", ICUResourceBundle.ICU_DATA_CLASS_LOADER); UResourceBundle codeMap = bundle.get("codeMap"); UResourceBundle numCode = codeMap.get(subType); result = numCode.getInt(); } catch (MissingResourceException e) { // fall through } return result; }
Example #4
Source File: RelativeDateTimeFormatter.java From fitnotifications with Apache License 2.0 | 6 votes |
public void consumeTimeDetail(UResource.Key key, UResource.Value value) { UResource.Table unitTypesTable = value.getTable(); EnumMap<RelativeUnit, String[][]> unitPatterns = styleRelUnitPatterns.get(style); if (unitPatterns == null) { unitPatterns = new EnumMap<RelativeUnit, String[][]>(RelativeUnit.class); styleRelUnitPatterns.put(style, unitPatterns); } String[][] patterns = unitPatterns.get(unit.relUnit); if (patterns == null) { patterns = new String[2][StandardPlural.COUNT]; unitPatterns.put(unit.relUnit, patterns); } // Stuff the pattern for the correct plural index with a simple formatter. for (int i = 0; unitTypesTable.getKeyAndValue(i, key, value); i++) { if (value.getType() == ICUResourceBundle.STRING) { int pluralIndex = StandardPlural.indexFromString(key.toString()); if (patterns[pastFutureIndex][pluralIndex] == null) { patterns[pastFutureIndex][pluralIndex] = SimpleFormatterImpl.compileToStringMinMaxArguments( value.getString(), sb, 0, 1); } } } }
Example #5
Source File: RelativeDateTimeFormatter.java From fitnotifications with Apache License 2.0 | 6 votes |
@Override public void put(UResource.Key key, UResource.Value value, boolean noFallback) { // Main entry point to sink if (value.getType() == ICUResourceBundle.ALIAS) { return; } UResource.Table table = value.getTable(); // Process each key / value in this table. for (int i = 0; table.getKeyAndValue(i, key, value); i++) { if (value.getType() == ICUResourceBundle.ALIAS) { handleAlias(key, value, noFallback); } else { // Remember style and unit for deeper levels. style = styleFromKey(key); int limit = key.length() - styleSuffixLength(style); unit = DateTimeUnit.orNullFromString(key.substring(0, limit)); if (unit != null) { // Process only if unitString is in the white list. consumeTimeUnit(key, value); } } } }
Example #6
Source File: RelativeDateTimeFormatter.java From fitnotifications with Apache License 2.0 | 6 votes |
private String getDateTimePattern(ICUResourceBundle r) { String calType = r.getStringWithFallback("calendar/default"); if (calType == null || calType.equals("")) { calType = "gregorian"; } String resourcePath = "calendar/" + calType + "/DateTimePatterns"; ICUResourceBundle patternsRb = r.findWithFallback(resourcePath); if (patternsRb == null && calType.equals("gregorian")) { // Try with gregorian. patternsRb = r.findWithFallback("calendar/gregorian/DateTimePatterns"); } if (patternsRb == null || patternsRb.getSize() < 9) { // Undefined or too few elements. return "{1} {0}"; } else { int elementType = patternsRb.get(8).getType(); if (elementType == UResourceBundle.ARRAY) { return patternsRb.get(8).getString(0); } else { return patternsRb.getString(8); } } }
Example #7
Source File: UResourceBundle.java From fitnotifications with Apache License 2.0 | 6 votes |
private static RootType getRootType(String baseName, ClassLoader root) { RootType rootType = ROOT_CACHE.get(baseName); if (rootType == null) { String rootLocale = (baseName.indexOf('.')==-1) ? "root" : ""; try{ ICUResourceBundle.getBundleInstance(baseName, rootLocale, root, true); rootType = RootType.ICU; }catch(MissingResourceException ex){ try{ ResourceBundleWrapper.getBundleInstance(baseName, rootLocale, root, true); rootType = RootType.JAVA; }catch(MissingResourceException e){ //throw away the exception rootType = RootType.MISSING; } } ROOT_CACHE.put(baseName, rootType); } return rootType; }
Example #8
Source File: MeasureFormat.java From fitnotifications with Apache License 2.0 | 6 votes |
/** * Consume a table of per-unit tables. For example, * unitsShort/duration contains tables for duration-unit subtypes day & hour. */ void consumeSubtypeTable(UResource.Key key, UResource.Value value) { unit = MeasureUnit.internalGetInstance(type, key.toString()); // never null // Trigger a fresh lookup of the patterns for this unit+width. patterns = null; if (value.getType() == ICUResourceBundle.STRING) { // Units like "coordinate" that don't have plural variants setFormatterIfAbsent(StandardPlural.OTHER.ordinal(), value, 0); } else if (value.getType() == ICUResourceBundle.TABLE) { // Units that have plural variants UResource.Table patternTableTable = value.getTable(); for (int i = 0; patternTableTable.getKeyAndValue(i, key, value); i++) { consumePattern(key, value); } } else { throw new ICUException("Data for unit '" + unit + "' is in an unknown format"); } }
Example #9
Source File: UResourceBundle.java From trekarta with GNU General Public License v3.0 | 5 votes |
/** * {@icu} Creates a UResourceBundle for the default locale and specified base name, * from which users can extract resources by using their corresponding keys. * @param baseName string containing the name of the data package. * If null the default ICU package name is used. * @return a resource bundle for the given base name and default locale * @stable ICU 3.0 */ public static UResourceBundle getBundleInstance(String baseName) { if (baseName == null) { baseName = ICUData.ICU_BASE_NAME; } ULocale uloc = ULocale.getDefault(); return getBundleInstance(baseName, uloc.getBaseName(), ICUResourceBundle.ICU_DATA_CLASS_LOADER, false); }
Example #10
Source File: Currency.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * Return an array of the locales for which a currency * is defined. * @return an array of the available locales * @stable ICU 2.2 */ public static Locale[] getAvailableLocales() { if (shim == null) { return ICUResourceBundle.getAvailableLocales(); } else { return shim.getAvailableLocales(); } }
Example #11
Source File: LocaleData.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * Returns LocaleDisplaySeparator for this locale. * @return locale display separator as a char. * @stable ICU 4.2 */ public String getLocaleSeparator() { String sub0 = "{0}"; String sub1 = "{1}"; ICUResourceBundle locDispBundle = (ICUResourceBundle) langBundle.get(LOCALE_DISPLAY_PATTERN); String localeSeparator = locDispBundle.getStringWithFallback(SEPARATOR); int index0 = localeSeparator.indexOf(sub0); int index1 = localeSeparator.indexOf(sub1); if (index0 >= 0 && index1 >= 0 && index0 <= index1) { return localeSeparator.substring(index0 + sub0.length(), index1); } return localeSeparator; }
Example #12
Source File: UResourceBundle.java From trekarta with GNU General Public License v3.0 | 5 votes |
/** * {@icu} Loads a new resource bundle for the given base name, locale and class loader. * Optionally will disable loading of fallback bundles. * @param baseName string containing the name of the data package. * If null the default ICU package name is used. * @param localeName the locale for which a resource bundle is desired * @param root the class object from which to load the resource bundle * @param disableFallback disables loading of fallback lookup chain * @throws MissingResourceException If no resource bundle for the specified base name * can be found * @return a resource bundle for the given base name and locale * @stable ICU 3.0 */ protected static UResourceBundle instantiateBundle(String baseName, String localeName, ClassLoader root, boolean disableFallback) { RootType rootType = getRootType(baseName, root); switch (rootType) { case ICU: return ICUResourceBundle.getBundleInstance(baseName, localeName, root, disableFallback); case JAVA: return ResourceBundleWrapper.getBundleInstance(baseName, localeName, root, disableFallback); case MISSING: default: UResourceBundle b; try{ b = ICUResourceBundle.getBundleInstance(baseName, localeName, root, disableFallback); setRootType(baseName, RootType.ICU); }catch(MissingResourceException ex){ b = ResourceBundleWrapper.getBundleInstance(baseName, localeName, root, disableFallback); setRootType(baseName, RootType.JAVA); } return b; } }
Example #13
Source File: UResourceBundle.java From trekarta with GNU General Public License v3.0 | 5 votes |
/** * {@icu} Creates a UResourceBundle, from which users can extract resources by using * their corresponding keys. * @param baseName string containing the name of the data package. * If null the default ICU package name is used. * @param locale specifies the locale for which we want to open the resource. * If null the bundle for default locale is opened. * @return a resource bundle for the given base name and locale * @stable ICU 3.0 */ public static UResourceBundle getBundleInstance(String baseName, ULocale locale) { if (baseName == null) { baseName = ICUData.ICU_BASE_NAME; } if (locale == null) { locale = ULocale.getDefault(); } return getBundleInstance(baseName, locale.getBaseName(), ICUResourceBundle.ICU_DATA_CLASS_LOADER, false); }
Example #14
Source File: UResourceBundle.java From trekarta with GNU General Public License v3.0 | 5 votes |
/** * {@icu} Creates a UResourceBundle for the specified locale and specified base name, * from which users can extract resources by using their corresponding keys. * @param baseName string containing the name of the data package. * If null the default ICU package name is used. * @param locale specifies the locale for which we want to open the resource. * If null the bundle for default locale is opened. * @return a resource bundle for the given base name and locale * @stable ICU 3.0 */ public static UResourceBundle getBundleInstance(String baseName, Locale locale) { if (baseName == null) { baseName = ICUData.ICU_BASE_NAME; } ULocale uloc = locale == null ? ULocale.getDefault() : ULocale.forLocale(locale); return getBundleInstance(baseName, uloc.getBaseName(), ICUResourceBundle.ICU_DATA_CLASS_LOADER, false); }
Example #15
Source File: UResourceBundle.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * {@icu} Loads a new resource bundle for the given base name, locale and class loader. * Optionally will disable loading of fallback bundles. * @param baseName string containing the name of the data package. * If null the default ICU package name is used. * @param localeName the locale for which a resource bundle is desired * @param root the class object from which to load the resource bundle * @param disableFallback disables loading of fallback lookup chain * @throws MissingResourceException If no resource bundle for the specified base name * can be found * @return a resource bundle for the given base name and locale * @stable ICU 3.0 */ protected static UResourceBundle instantiateBundle(String baseName, String localeName, ClassLoader root, boolean disableFallback) { RootType rootType = getRootType(baseName, root); switch (rootType) { case ICU: return ICUResourceBundle.getBundleInstance(baseName, localeName, root, disableFallback); case JAVA: return ResourceBundleWrapper.getBundleInstance(baseName, localeName, root, disableFallback); case MISSING: default: UResourceBundle b; try{ b = ICUResourceBundle.getBundleInstance(baseName, localeName, root, disableFallback); setRootType(baseName, RootType.ICU); }catch(MissingResourceException ex){ b = ResourceBundleWrapper.getBundleInstance(baseName, localeName, root, disableFallback); setRootType(baseName, RootType.JAVA); } return b; } }
Example #16
Source File: CollationLoader.java From fitnotifications with Apache License 2.0 | 5 votes |
static String loadRules(ULocale locale, String collationType) { UResourceBundle bundle = UResourceBundle.getBundleInstance( ICUData.ICU_COLLATION_BASE_NAME, locale); UResourceBundle data = ((ICUResourceBundle)bundle).getWithFallback( "collations/" + ASCII.toLowerCase(collationType)); String rules = data.getString("Sequence"); return rules; }
Example #17
Source File: LocaleData.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * Returns the current CLDR version * @stable ICU 4.2 */ public static VersionInfo getCLDRVersion() { // fetching this data should be idempotent. if(gCLDRVersion == null) { // from ZoneMeta.java UResourceBundle supplementalDataBundle = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, "supplementalData", ICUResourceBundle.ICU_DATA_CLASS_LOADER); UResourceBundle cldrVersionBundle = supplementalDataBundle.get("cldrVersion"); gCLDRVersion = VersionInfo.getInstance(cldrVersionBundle.getString()); } return gCLDRVersion; }
Example #18
Source File: MeasureUnit.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * Populate the MeasureUnit cache with all types from the data. * Population is done lazily, in response to MeasureUnit.getAvailable() * or other API that expects to see all of the MeasureUnits. * * <p>At static initialization time the MeasureUnits cache is populated * with public static instances (G_FORCE, METER_PER_SECOND_SQUARED, etc.) only. * Adding of others is deferred until later to avoid circular static init * dependencies with classes Currency and TimeUnit. * * <p>Synchronization: this function must be called from static synchronized methods only. * * @internal */ static private void populateCache() { if (cacheIsPopulated) { return; } cacheIsPopulated = true; /* Schema: * * units{ * duration{ * day{ * one{"{0} ден"} * other{"{0} дена"} * } */ // Load the unit types. Use English, since we know that that is a superset. ICUResourceBundle rb1 = (ICUResourceBundle) UResourceBundle.getBundleInstance( ICUData.ICU_UNIT_BASE_NAME, "en"); rb1.getAllItemsWithFallback("units", new MeasureUnitSink()); // Load the currencies ICUResourceBundle rb2 = (ICUResourceBundle) UResourceBundle.getBundleInstance( ICUData.ICU_BASE_NAME, "currencyNumericCodes", ICUResourceBundle.ICU_DATA_CLASS_LOADER); rb2.getAllItemsWithFallback("codeMap", new CurrencyNumericCodeSink()); }
Example #19
Source File: TimeZone.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * {@icu} Converts a system time zone ID to an equivalent Windows time zone ID. For example, * Windows time zone ID "Pacific Standard Time" is returned for input "America/Los_Angeles". * * <p>There are system time zones that cannot be mapped to Windows zones. When the input * system time zone ID is unknown or unmappable to a Windows time zone, then this * method returns <code>null</code>. * * <p>This implementation utilizes <a href="http://unicode.org/cldr/charts/supplemental/zone_tzid.html"> * Zone-Tzid mapping data</a>. The mapping data is updated time to time. To get the latest changes, * please read the ICU user guide section <a href="http://userguide.icu-project.org/datetime/timezone#TOC-Updating-the-Time-Zone-Data"> * Updating the Time Zone Data</a>. * * @param id A system time zone ID * @return A Windows time zone ID mapped from the input system time zone ID, * or <code>null</code> when the input ID is unknown or unmappable. * @see #getIDForWindowsID(String, String) * * @stable ICU 52 */ public static String getWindowsID(String id) { // canonicalize the input ID boolean[] isSystemID = {false}; id = getCanonicalID(id, isSystemID); if (!isSystemID[0]) { // mapping data is only applicable to tz database IDs return null; } UResourceBundle top = UResourceBundle.getBundleInstance( ICUData.ICU_BASE_NAME, "windowsZones", ICUResourceBundle.ICU_DATA_CLASS_LOADER); UResourceBundle mapTimezones = top.get("mapTimezones"); UResourceBundleIterator resitr = mapTimezones.getIterator(); while (resitr.hasNext()) { UResourceBundle winzone = resitr.next(); if (winzone.getType() != UResourceBundle.TABLE) { continue; } UResourceBundleIterator rgitr = winzone.getIterator(); while (rgitr.hasNext()) { UResourceBundle regionalData = rgitr.next(); if (regionalData.getType() != UResourceBundle.STRING) { continue; } String[] tzids = regionalData.getString().split(" "); for (String tzid : tzids) { if (tzid.equals(id)) { return winzone.getKey(); } } } } return null; }
Example #20
Source File: GenderInfo.java From fitnotifications with Apache License 2.0 | 5 votes |
private static GenderInfo load(ULocale ulocale) { UResourceBundle rb = UResourceBundle.getBundleInstance( ICUData.ICU_BASE_NAME, "genderList", ICUResourceBundle.ICU_DATA_CLASS_LOADER, true); UResourceBundle genderList = rb.get("genderList"); try { return new GenderInfo( ListGenderStyle.fromName(genderList.getString(ulocale.toString()))); } catch (MissingResourceException mre) { return null; } }
Example #21
Source File: LocaleMatcher.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * @internal * @deprecated This API is ICU internal only. */ @Deprecated public static ICUResourceBundle getICUSupplementalData() { ICUResourceBundle suppData = (ICUResourceBundle) UResourceBundle.getBundleInstance( ICUData.ICU_BASE_NAME, "supplementalData", ICUResourceBundle.ICU_DATA_CLASS_LOADER); return suppData; }
Example #22
Source File: DateIntervalFormat.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * Retrieves the concatenation DateTime pattern from the resource bundle. * @param locale Locale to retrieve. * @return Concatenation DateTime pattern. */ private String getConcatenationPattern(ULocale locale) { ICUResourceBundle rb = (ICUResourceBundle) UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, locale); ICUResourceBundle dtPatternsRb = rb.getWithFallback("calendar/gregorian/DateTimePatterns"); ICUResourceBundle concatenationPatternRb = (ICUResourceBundle) dtPatternsRb.get(8); if (concatenationPatternRb.getType() == UResourceBundle.STRING) { return concatenationPatternRb.getString(); } else { return concatenationPatternRb.getString(0); } }
Example #23
Source File: UResourceBundle.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * {@icu} Creates a UResourceBundle, from which users can extract resources by using * their corresponding keys. * @param baseName string containing the name of the data package. * If null the default ICU package name is used. * @param locale specifies the locale for which we want to open the resource. * If null the bundle for default locale is opened. * @return a resource bundle for the given base name and locale * @stable ICU 3.0 */ public static UResourceBundle getBundleInstance(String baseName, ULocale locale) { if (baseName == null) { baseName = ICUData.ICU_BASE_NAME; } if (locale == null) { locale = ULocale.getDefault(); } return getBundleInstance(baseName, locale.getBaseName(), ICUResourceBundle.ICU_DATA_CLASS_LOADER, false); }
Example #24
Source File: UResourceBundle.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * {@icu} Creates a UResourceBundle for the specified locale and specified base name, * from which users can extract resources by using their corresponding keys. * @param baseName string containing the name of the data package. * If null the default ICU package name is used. * @param locale specifies the locale for which we want to open the resource. * If null the bundle for default locale is opened. * @return a resource bundle for the given base name and locale * @stable ICU 3.0 */ public static UResourceBundle getBundleInstance(String baseName, Locale locale) { if (baseName == null) { baseName = ICUData.ICU_BASE_NAME; } ULocale uloc = locale == null ? ULocale.getDefault() : ULocale.forLocale(locale); return getBundleInstance(baseName, uloc.getBaseName(), ICUResourceBundle.ICU_DATA_CLASS_LOADER, false); }
Example #25
Source File: UResourceBundle.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * {@icu} Creates a UResourceBundle for the default locale and specified base name, * from which users can extract resources by using their corresponding keys. * @param baseName string containing the name of the data package. * If null the default ICU package name is used. * @return a resource bundle for the given base name and default locale * @stable ICU 3.0 */ public static UResourceBundle getBundleInstance(String baseName) { if (baseName == null) { baseName = ICUData.ICU_BASE_NAME; } ULocale uloc = ULocale.getDefault(); return getBundleInstance(baseName, uloc.getBaseName(), ICUResourceBundle.ICU_DATA_CLASS_LOADER, false); }
Example #26
Source File: LocaleData.java From trekarta with GNU General Public License v3.0 | 5 votes |
/** * Returns LocaleDisplaySeparator for this locale. * @return locale display separator as a char. * @stable ICU 4.2 */ public String getLocaleSeparator() { String sub0 = "{0}"; String sub1 = "{1}"; ICUResourceBundle locDispBundle = (ICUResourceBundle) langBundle.get(LOCALE_DISPLAY_PATTERN); String localeSeparator = locDispBundle.getStringWithFallback(SEPARATOR); int index0 = localeSeparator.indexOf(sub0); int index1 = localeSeparator.indexOf(sub1); if (index0 >= 0 && index1 >= 0 && index0 <= index1) { return localeSeparator.substring(index0 + sub0.length(), index1); } return localeSeparator; }
Example #27
Source File: Collator.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * Returns the set of locales, as Locale objects, for which collators * are installed. Note that Locale objects do not support RFC 3066. * @return the list of locales in which collators are installed. * This list includes any that have been registered, in addition to * those that are installed with ICU4J. * @stable ICU 2.4 */ public static Locale[] getAvailableLocales() { // TODO make this wrap getAvailableULocales later if (shim == null) { return ICUResourceBundle.getAvailableLocales( ICUData.ICU_COLLATION_BASE_NAME, ICUResourceBundle.ICU_DATA_CLASS_LOADER); } return shim.getAvailableLocales(); }
Example #28
Source File: SimpleDateFormat.java From fitnotifications with Apache License 2.0 | 5 votes |
private static synchronized String getDefaultPattern() { ULocale defaultLocale = ULocale.getDefault(Category.FORMAT); if (!defaultLocale.equals(cachedDefaultLocale)) { cachedDefaultLocale = defaultLocale; Calendar cal = Calendar.getInstance(cachedDefaultLocale); try { // Load the calendar data directly. ICUResourceBundle rb = (ICUResourceBundle) UResourceBundle.getBundleInstance( ICUData.ICU_BASE_NAME, cachedDefaultLocale); String resourcePath = "calendar/" + cal.getType() + "/DateTimePatterns"; ICUResourceBundle patternsRb= rb.findWithFallback(resourcePath); if (patternsRb == null) { patternsRb = rb.findWithFallback("calendar/gregorian/DateTimePatterns"); } if (patternsRb == null || patternsRb.getSize() < 9) { cachedDefaultPattern = FALLBACKPATTERN; } else { int defaultIndex = 8; if (patternsRb.getSize() >= 13) { defaultIndex += (SHORT + 1); } String basePattern = patternsRb.getString(defaultIndex); cachedDefaultPattern = SimpleFormatterImpl.formatRawPattern( basePattern, 2, 2, patternsRb.getString(SHORT), patternsRb.getString(SHORT + 4)); } } catch (MissingResourceException e) { cachedDefaultPattern = FALLBACKPATTERN; } } return cachedDefaultPattern; }
Example #29
Source File: ListFormatter.java From fitnotifications with Apache License 2.0 | 5 votes |
private static ListFormatter load(ULocale ulocale, String style) { ICUResourceBundle r = (ICUResourceBundle)UResourceBundle. getBundleInstance(ICUData.ICU_BASE_NAME, ulocale); StringBuilder sb = new StringBuilder(); return new ListFormatter( compilePattern(r.getWithFallback("listPattern/" + style + "/2").getString(), sb), compilePattern(r.getWithFallback("listPattern/" + style + "/start").getString(), sb), compilePattern(r.getWithFallback("listPattern/" + style + "/middle").getString(), sb), compilePattern(r.getWithFallback("listPattern/" + style + "/end").getString(), sb), ulocale); }
Example #30
Source File: LocaleData.java From trekarta with GNU General Public License v3.0 | 5 votes |
/** * Retrieves a delimiter string from the locale data. * * @param type The type of delimiter string desired. Currently, * the valid choices are QUOTATION_START, QUOTATION_END, * ALT_QUOTATION_START, or ALT_QUOTATION_END. * @return The desired delimiter string. * @stable ICU 3.4 */ public String getDelimiter(int 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 && !bundle.isRoot() && stringBundle.isRoot()) { return null; } return stringBundle.getString(); }