[iPhone] Language detection using navigator.language

1,888 views
Skip to first unread message

mobweb

unread,
Feb 2, 2010, 11:25:42 AM2/2/10
to phonegap
Hello all,

I'm using navigator.language to detect the language set on the device
and display my app in that language, if possible.

My app is available in 3 languages: English, German and French.

Now obviously I am looking for "en-us", "de-de" and "fr-fr", and just
fallback to English if none of these languages where detected, but I'm
wondering if in some cases it could also say "en-gb" (for GB devices),
"de-ch" (for Swiss devices) or "de-at" (for Austrian devices).

Does anyone have any further information on that topic?

Thanks,

Thomas

unread,
Feb 2, 2010, 12:45:19 PM2/2/10
to phonegap
You can read on it more over here http://www.langtag.net/ <-

basically I'd recommend you to detect just the first bit and chose
language based on that, there might be many different dialects/
variations you could skip unintentionally so I guess just testing the
'root' language would be the best bet

regards
Tom

mobweb

unread,
Feb 2, 2010, 1:13:19 PM2/2/10
to phonegap
Alright, thanks.

Here's how I got it working:

language = navigator.language.split("-");
language_root = (language[0]);

Regards

On 2 Feb., 18:45, Thomas <tomasztu...@gmail.com> wrote:
> You can read on it more over herehttp://www.langtag.net/<-

Reply all
Reply to author
Forward
0 new messages