How can I detect the system language of an iOS device using JavaScript? [duplicate]

懵懂的女人 提交于 2020-02-27 05:04:19

问题


I have found this previous question but it uses C. Is there a way to do this through JQuery or JavaScript?


回答1:


UPDATE: This plugin is not required any more, and its no longer included in default installations. The current way of obtaining it is navigator.language() See https://developer.mozilla.org/es/docs/Web/API/NavigatorLanguage/language


Below method will help you to find your device language using Cordova/Phonegap.

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

Note: Check the Cordova Globalization plugin documentation for more.



来源:https://stackoverflow.com/questions/19490975/how-can-i-detect-the-system-language-of-an-ios-device-using-javascript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!