According to the javadoc for Locale.getDisplayLanguage(Locale inLocale)
,
Returns a name for the locale's country that is appropriate for display to the user. If possible, the name returned will be localized according to inLocale. For example, if the locale is fr_FR and inLocale is en_US, getDisplayCountry() will return "France"; if the locale is en_US and inLocale is fr_FR, getDisplayCountry() will return "Etats-Unis". If the name returned cannot be localized according to inLocale. (say, we don't have a Japanese name for Croatia), this function falls back on the English name, and finally on the ISO code as a last-resort value. If the locale doesn't specify a country, this function returns the empty string.
So, when I execute the following code snippet:
final class TurkishDemo
{
public static void main(String[] args)
{
final Locale l = new Locale("tr");
for(Locale locale: Locale.getAvailableLocales())
{
System.out.println(locale.getDisplayCountry(l));
}
}
}
And I get the following output:
Japan Peru
Japan Panama Bosnia and Herzegovina
Guatemala United Arab Emirates Norway Albania
Iraq Yemen
Portugal Cyprus Qatar Macedonia
Switzerland United States Finland
Malta Slovenia Slovakia
Türkiye
Saudi Arabia
United Kingdom Serbia and Montenegro
New Zealand Norway Lithuania Nicaragua
Ireland Belgium Spain Lebanon
Canada Estonia Kuwait Serbia United States Mexico Sudan Indonesia
Uruguay Latvia
Brazil Syria
Dominican Republic Switzerland India Venezuela Bahrain Philippines Tunisia
Austria
Netherlands Ecuador Taiwan Jordan
Iceland Colombia Costa Rica Chile Egypt South Africa Thailand Greece Italy
Hungary
Ireland Ukraine Poland Luxembourg Belgium India Spain Morocco Bolivia Australia
Singapore
El Salvador Russia South Korea
Algeria Vietnam Montenegro
Libya
China Belarus Hong Kong
Israel Bulgaria
Malta Paraguay
France Czech Republic Switzerland Romania Puerto Rico Canada Germany
Luxembourg
Argentina
Malaysia Croatia Singapore
Oman
Thailand
Sweden Denmark Honduras
You'll notice that nearly all (except Turkey) falls back to the English display country name. Is this to be expected, or am I doing something wrong?
I think your code is correct. I got the same behavior running the code in my machine. It seems that JDK doesn't have Turkish translations for these country names except for Turkey itself.