Created
August 15, 2014 19:54
-
-
Save raphaelluchini/066806cafd080dcefd50 to your computer and use it in GitHub Desktop.
Set JQqueryUI DatePicker to browser languarge, requires jquery-ui-i18n.js
This file contains hidden or 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 getJqueryUserLanguage = function() { | |
if (navigator.language.toLowerCase() == 'en-us') { | |
return ''; | |
} | |
else { | |
var l = navigator.language.toLowerCase().split('-'); | |
if (l.length == 1) { | |
if ($.datepicker.regional[l[0]] != undefined) return l[0]; | |
else return ''; | |
} | |
else if (l.length > 1) { | |
if ($.datepicker.regional[l[0] + '-' + l[1].toUpperCase()] != undefined) return l[0] + '-' + l[1].toUpperCase(); | |
else if ($.datepicker.regional[l[0]] != undefined) return l[0]; | |
else return ''; | |
} | |
else { | |
return ''; | |
} | |
} | |
} | |
$.datepicker.setDefaults( $.datepicker.regional[ getJqueryUserLanguage() ] ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment