Skip to content

Instantly share code, notes, and snippets.

@raphaelluchini
Created August 15, 2014 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raphaelluchini/066806cafd080dcefd50 to your computer and use it in GitHub Desktop.
Save raphaelluchini/066806cafd080dcefd50 to your computer and use it in GitHub Desktop.
Set JQqueryUI DatePicker to browser languarge, requires jquery-ui-i18n.js
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