+ return locales.get(getDefaultIndex());
+ }
+
+ /** Returns null if argument is null. */
+ public static List<Locale> asLocaleList(Object locales) {
+ if (locales == null)
+ return null;
+ ArrayList<Locale> availableLocales = new ArrayList<Locale>();
+ String[] codes = locales.toString().split(",");
+ for (int i = 0; i < codes.length; i++) {
+ String code = codes[i];
+ // variant not supported
+ int indexUnd = code.indexOf("_");
+ Locale locale;
+ if (indexUnd > 0) {
+ String language = code.substring(0, indexUnd);
+ String country = code.substring(indexUnd + 1);
+ locale = new Locale(language, country);
+ } else {
+ locale = new Locale(code);
+ }
+ availableLocales.add(locale);
+ }
+ return availableLocales;