What is the difference between 'de' and 'de-DE' language codes?

bhelm picture bhelm · Jan 16, 2017 · Viewed 16.5k times · Source

I notice that i can choose in some places* between those languages:

  • de - German - Deutsch
  • de-DE - Deutsch(Deutschland) - German(Germany)

*Android initial device setup, chromium browser in language settings. if one selects de-DE in chromium, it automatically adds de too.

i know that de-DE means 'German as spoken in Germany'. but i dont know a other country where german is spoken that does not have its own language variant (like de-CH for switzerland or de-AT for austria).

so what is the reason for having both variants to chose from? do they have any actual difference? i could imagine that people from switzerland use de-CH as primary language and de as fallback, but they could also use de-DE for that purpose, right?

i know that there is es-ES for spain and 'es' for other countries where espanol is spoken, but that do not have their own variant code.

Background: i want to track how many users use which primary language (browser header) and im not sure if de and de-de should be counted together or seperate, and whats the differences is. i use the language database from http://peric.github.io/GetCountries/ which has 'de' but no 'de-DE' language. is the database correct with having only 'de'?

Answer

Mihai Nita picture Mihai Nita · Jan 18, 2017

A lot of environments (browsers, Android) use one single locale setting both for selecting the language of the UI, and to format numbers, dates, times, etc.

If you select de-CH (for instance in Android N) you will get "German" strings (the Android translation is "generic German"), but Swiss dates / times / etc. For instance the numbers use apostrophe as thousand separator (like 1'234'567,89), the currency formatter will use CHF, and so on.

On Android before N you selected "German" from the language list, but the default locale set was de-DE ("German" without region was just a UI thing)

To track user settings: unfortunately, just "de" or "de-DE" is not a reliable signal, as not all systems allow for a region selection. But if you see something else (for instance en-CH), then it is more reliable.

You can also try to correlate with info from the IP address. If my setting says "de" and my IP address is in Austria, you might infer that in fact I prefer de-AT (not 100% reliable, but better than "de").