Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Locale.UK and country code

According to the ISO 2 character codes uk = United Kingdom. But Locale.UK.getCountry() is returning GB. Am I missing something?

like image 257
Aravind Yarram Avatar asked Dec 01 '11 00:12

Aravind Yarram


People also ask

How do I find my locale country code?

Use of LocaleUse getCountry to get the country (or region) code and getLanguage to get the language code. You can use getDisplayCountry to get the name of the country suitable for displaying to the user.

What is locale en GB?

To specify a specific dialect, use a hyphen to combine a language designator with a region designator. For example, to specify common English, use the en language designator as locale. To specify the English language as it is used in the United Kingdom, use en-GB as the locale.

What is locale English?

As defined by Microsoft, a locale is either a language or a language in combination with a country. See below for the definitions of locale and LCID and other resources.

What is locale getDefault in java?

getDefault(Locale.Category category) Gets the current value of the default locale for the specified Category for this instance of the Java Virtual Machine. String. getDisplayCountry() Returns a name for the locale's country that is appropriate for display to the user.


2 Answers

According to this,

The getCountry() method returns the ISO 3166 two-letter abbreviation for the locale's region or country member.

The ISO 3166 two-letter abbreviation for the UK is indeed GB. uk is not part of the standard, but more of a historical accident:

The use of .uk rather than .gb for the top-level domain is due to its pre-existing use in the (now obsolete) JANET Name Registration Scheme in which the order of address components were reversed. .uk was made available in DNS to simplify the translation to and from these addresses. There were plans for eventual transition to .gb to accord with correct usage, but this never occurred; the use of .uk is now entrenched, and it is impossible to register a .gb domain.

Depending on your target use, you may need to replace .gb with .uk.

like image 101
Pekka Avatar answered Nov 07 '22 10:11

Pekka


uk is there for compatibility reasons (a mistake in the past).

The correct id is gb.

The only place where gb remains standard is the domain names, but this is outside the scope of this question.

To minimize potential issues you could remap uk to gb.

like image 25
sorin Avatar answered Nov 07 '22 10:11

sorin