@Nullable private static List<Locale> extractLocalesFromString(final String rawLocales) { if (rawLocales.isEmpty()) { return Collections.emptyList(); } final String[] splitRawLocales = rawLocales.split(","); final List<Locale> locales = new ArrayList<>(splitRawLocales.length); for (String rawLocale : splitRawLocales) { final Locale locale = PropertiesUtil.getLocale("_" + rawLocale + ".properties"); if (locale == PropertiesUtil.DEFAULT_LOCALE) { return null; } else if (!locales.contains(locale)) { locales.add(locale); } } return locales; }
private MyExistLocalesListModel() { myLocales = new ArrayList<>(); myLocales.add(PropertiesUtil.DEFAULT_LOCALE); PropertiesReferenceManager.getInstance(myProject) .processPropertiesFiles( GlobalSearchScope.projectScope(myProject), new PropertiesFileProcessor() { @Override public boolean process(String baseName, PropertiesFile propertiesFile) { final Locale locale = propertiesFile.getLocale(); if (locale != PropertiesUtil.DEFAULT_LOCALE && !myLocales.contains(locale)) { myLocales.add(locale); } return true; } }, BundleNameEvaluator.DEFAULT); Collections.sort(myLocales, LOCALE_COMPARATOR); }