Created
April 11, 2013 10:24
-
-
Save Marthyn/5362304 to your computer and use it in GitHub Desktop.
Language detection, normal browser and phonegap.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var detectLanguage = function(successCB, errorCB) { | |
//Phonegap browser detection | |
if (navigator.globalization !== null && navigator.globalization !== undefined) { | |
navigator.globalization.getPreferredLanguage( | |
function (language) { successCB(language); }, | |
function (error) { errorCB(error); } | |
); | |
//Normal browser detection | |
} else { | |
if(window.navigator.language !== null && window.navigator.language !== undefined) { | |
successCB(window.navigator.language); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment