Zsolt Takács
Zsolt Takács

Reputation: 364

How do i get the native language localisation on a smartphone from browser javascript?

I'm working on a mobile website and I want to change languages by the phone native defaults.

Is there any solution to do it? I mean there are three states:

  1. the phone lang setting is "eng"
  2. the phone lang setting is "hun"
  3. the phone lang setting is other foreign lang, then the website lang is "eng"

I want to use it on iOS and Android too.

Thx

Upvotes: 3

Views: 297

Answers (1)

Taifun
Taifun

Reputation: 6293

in case you are still interested in an answer:
you can use navigator.appVersion, see the following JavaScript snippet:

  <script type="text/javascript">
    alert(navigator.appVersion);
  </script>

and the corresponding result on a Android device with Android 2.2:
screenshot
you just have to parse for the language, in the example it is de-de.
Sorry, I do not have an iPhone, but the result is probably similar...

Upvotes: 2

Related Questions