Phonegap iOS retrieve device language

前端 未结 2 1078
梦谈多话
梦谈多话 2021-01-14 16:56

I\'m doing a Phonegap hybrid app and i have to retrieve the device language, eg: \"IT\", \"EN\". Any suggestions on this?

相关标签:
2条回答
  • 2021-01-14 17:27

    Regarding your question the answers is:

     var lang = navigator.language.split("-");
     var current_lang = (lang[0]);
     alert( "current_lang: " + current_lang );
    
    0 讨论(0)
  • 2021-01-14 17:30

    There's (now) the Globalization API in Cordova to retrieve that kind of info (you can also get info for dates, currency, ...):

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

    See http://docs.phonegap.com/en/3.3.0/cordova_globalization_globalization.md.html#Globalization

    0 讨论(0)
提交回复
热议问题