开发者

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

开发者 https://www.devze.com 2023-03-01 05:38 出处:网络
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:

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


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:

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


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...

0

精彩评论

暂无评论...
验证码 换一张
取 消