Domanda

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.

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top