4

我正在做一个 Phonegap 混合应用程序,我必须检索设备语言,例如:“IT”、“EN”。对此有何建议?

4

2 回答 2

14

关于你的问题,答案是:

 var lang = navigator.language.split("-");
 var current_lang = (lang[0]);
 alert( "current_lang: " + current_lang );
于 2012-07-24T07:09:37.123 回答
4

Cordova 中有(现在)Globalization API 来检索此类信息(您还可以获取日期、货币等信息):

globalization.getPreferredLanguage
globalization.getLocaleName
globalization.dateToString
globalization.stringToDate
globalization.getDatePattern
globalization.getDateNames
globalization.isDayLightSavingsTime
globalization.getFirstDayOfWeek
globalization.numberToString
globalization.stringToNumber
globalization.getNumberPattern
globalization.getCurrencyPattern

请参阅http://docs.phonegap.com/en/3.3.0/cordova_globalization_globalization.md.html#Globalization

于 2014-03-07T03:54:37.633 回答