11

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

5
  • You mentioned JavaScript, can I assume your codes will be loaded in UIWebView ? Commented Oct 21, 2013 at 9:43
  • This is for browsers, will it work the same on an iOS iPad app? Commented Oct 21, 2013 at 9:43
  • I am using Cordova @Shivan, so I haven't used or changed any Objective C code. Commented Oct 21, 2013 at 9:45
  • Then it's not related to other tags. Retag as Cordova / PhoneGap . Commented Oct 21, 2013 at 9:51
  • Sorry I am new to this. Thanks for the link I will have a read now. Commented Oct 21, 2013 at 9:54

1 Answer 1

13

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Is there any reason to prefer navigator.globalization.getPreferredLanguage vs navigator.language ?
Now in 2018, use navigator.language. There is a deprecation notice on the readme of the cordova plugin.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.