我正在做一个Phonegap混合应用程序,我必须检索设备语言,例如:“IT”,“EN”。对此有何建议?
答案 0 :(得分:13)
关于你的问题,答案是:
var lang = navigator.language.split("-");
var current_lang = (lang[0]);
alert( "current_lang: " + current_lang );
答案 1 :(得分: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