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").
Answer from Mihai Nita on Stack OverflowVideos
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").
It depends what you want to count. I'm from Switzerland my browser code is de-CH and de as a fallback. So, if you just want to count all German speaking countries, using de should be enough. Just make sure you also add all de-CH entries to de. Not everybody will have the fallback in their browsers.