public static String translateCountryName ( String country , Locale language ) { country = StringUtils . trimToNull ( country ) ; if ( country == null ) return null ; for ( String iso2Code : Locale . getISOCountries ( ) ) { Locale countryLocale = new Locale ( iso2Code , iso2Code ) ; for ( Locale translationLocale : LocaleUtils . availableLocaleList ( ) ) { String name = StringUtils . trimToNull ( countryLocale . getDisplayCountry ( translationLocale ) ) ; if ( name != null && name . equalsIgnoreCase ( country ) ) { name = StringUtils . trimToNull ( countryLocale . getDisplayCountry ( language ) ) ; if ( name != null ) return name ; } } } return null ; }
Translate a country name into another language .