문제

How can I get all the language strings that comply to the returned value of the success function parameter that is passed when calling:

navigator.globalization.getPreferredLanguage(
  function (language) {alert('language: ' + language.value + '\n');},
  function () {alert('Error getting language\n');}
);

source

When I run this code on my Android devices I get "English", however in some places I read that it returns the name of the language in the original language, for example, it will return '中国的' for Chinese.

I need this returned value in order to change the UI language.

도움이 되었습니까?

해결책

I'd use the function getLocaleName for this, and then use the first two chars given. The values given can be found here.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top