public static String[] valuesWithFullNames() { LANGUAGE[] allValues = values(); ArrayList<String> result = new ArrayList<String>(allValues.length); for (int i = 0; i < allValues.length; i++) { // We will return the full names sorted alphabetically. To ensure that the user // notices the special "UNLISTED" language code, we add it to the end of the list // after sorting, so now we skip it. if(allValues[i] != UNLISTED) result.add(allValues[i].fullName); } Collections.sort(result); result.add(UNLISTED.fullName); return result.toArray(new String[result.size()]); }
/** * Create a new LANGUAGE object from either its short code, its full * name or its ISO code. * @param whatever Short code, full name or ISO code. * @return LANGUAGE */ public static LANGUAGE mapToLanguage(String whatever) { for (LANGUAGE currentLanguage : LANGUAGE.values()) { if (currentLanguage.shortCode.equalsIgnoreCase(whatever) || currentLanguage.fullName.equalsIgnoreCase(whatever) || currentLanguage.isoCode.equalsIgnoreCase(whatever) || currentLanguage.toString().equalsIgnoreCase(whatever)) { return currentLanguage; } if(currentLanguage.aliases != null) { for(String s : currentLanguage.aliases) if(whatever.equalsIgnoreCase(s)) return currentLanguage; } } return null; }
public void testStrings() throws Exception { for (LANGUAGE lang : LANGUAGE.values()) { BaseL10n l10n = createL10n(lang); SimpleFieldSet fields = l10n.getCurrentLanguageTranslation(); if (fields != null) { for (Iterator<String> itr = fields.keyIterator(); itr.hasNext();) { String key = itr.next(); String value = fields.get(key); try { l10n.attemptParse(value); } catch (L10nParseException e) { fail("Error in "+key+" for "+lang+": "+e.getMessage()); } } } } }