static { ResourceBundle rb = ResourceBundle.getBundle( "calendar/" + ISO_CALENDAR_TYPE, Locale.ROOT, getDefaultLoader(), UTF8ResourceControl.SINGLETON); String[] languages = rb.getString("languages").split(" "); Set<String> tmp = new HashSet<>(); Collections.addAll(tmp, languages); LANGUAGES = Collections.unmodifiableSet(tmp); Set<Locale> locs = new HashSet<>(); for (String lang : LANGUAGES) { locs.add(new Locale(lang)); } // defensive strategy in case JDK should change its behaviour for (LanguageMatch lm : LanguageMatch.values()) { locs.add(new Locale(lm.name())); // in Java 8 or earlier no effect } LOCALES = Collections.unmodifiableSet(locs); }
private static ResourceBundle getBundle(Locale desired) throws MissingResourceException { if (LANGUAGES.contains(LanguageMatch.getAlias(desired))) { return ResourceBundle.getBundle( "calendar/" + ISO_CALENDAR_TYPE, desired, getDefaultLoader(), UTF8ResourceControl.SINGLETON); } return null; }