private MessageBundle getParentBundle(GadgetSpec spec, Locale locale, bool ignoreCache) { if (locale.getLanguage().Equals("all")) { // Top most locale already. return null; } if (locale.getCountry().Equals("ALL")) { return getBundle(spec, new Locale("all", "ALL"), ignoreCache); } return getBundle(spec, new Locale(locale.getLanguage(), "ALL"), ignoreCache); }
/** * Attempts to retrieve a valid LocaleSpec for the given Locale. * First tries to find an exact language / country match. * Then tries to find a match for language / all. * Then tries to find a match for all / all. * Finally gives up. * @param locale * @return The locale spec, if there is a matching one, or null. */ public LocaleSpec getLocale(Locale locale) { if (locales.Count == 0) { return null; } LocaleSpec localeSpec = null; if (!locales.TryGetValue(locale, out localeSpec)) { locale = new Locale(locale.getLanguage(), "ALL"); if (!locales.TryGetValue(locale, out localeSpec)) { locales.TryGetValue(GadgetSpec.DEFAULT_LOCALE, out localeSpec); } } return localeSpec; }