public String toString(String translationCode) { StringBuilder currentTranslation = new StringBuilder(Languages.getName(translationCode)); if (translationCode.indexOf('_') != -1) { String[] locale = StringUtil.split(translationCode, '_'); currentTranslation.append(", "); currentTranslation.append(Countries.getCountry(locale[1])); } return currentTranslation.toString(); }
/** * Get the country name from the country code. If the code is null or empty * then it is considered to be DEFAULT_COUNTRY_CODE (that is, US). * Otherwise, it will generate a log message and return unknown. If a locale * is used for the iso3166Code, it will use the part before the '_'. Thus, * this code does not support dialects, except as found in the iso3166. * * @param iso3166Code the country code * @return the name of the country */ public static String getCountry(String iso3166Code) { String lookup = iso3166Code; if (lookup == null || lookup.length() == 0) { return getCountry(DEFAULT_COUNTRY_CODE); } if (lookup.indexOf('_') != -1) { String[] locale = StringUtil.split(lookup, '_'); return getCountry(locale[1]); } try { return getLocalisedCountries().getString(lookup); } catch (MissingResourceException e) { return getCountry(UNKNOWN_COUNTRY_CODE); } }