11

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

Community
  • 1
  • 1
LiddleLaLoo
  • 133
  • 2
  • 2
  • 8

1 Answers1

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.

mjuopperi
  • 773
  • 7
  • 25
Mumthezir VP
  • 6,251
  • 6
  • 28
  • 57
  • 4
    Is there any reason to prefer `navigator.globalization.getPreferredLanguage` vs `navigator.language` ? – LuckyStarr Oct 26 '17 at 12:33
  • 5
    Now in 2018, use `navigator.language`. There is a deprecation notice on the readme of the cordova plugin. – e666 Apr 06 '18 at 08:24