eternicode/bootstrap-datepicker — pull request #320 by johnnyreilly (2013-01-12 14:08:32+00:00)
Title: Now supports full IETF codes & 2 letter codes

Hi Andrew,

This is a minor change related to language support in Bootstrap Datepicker (1 line change in the main file). I've also updated the README to reflect the change in usage. Anyone switching to using this amended branch would not have to make any changes to their code to cater for this change; they'd just benefit from the extra fallback functionality if they wanted to use it.

The picker now supports full IETF codes (eg "en" for English, "pt-BR" for Brazilian Portuguese) of the language to use for month and day names. If a full code (eg "de-DE") is supplied the picker will first check for an "de-DE" language and if not found it will fallback and check for a "de" language instead.

Without this in place I need to do something like this to achieve the same aim:

var currentCulture = $("meta[name='accept-language']").prop("content"), //Where the tag contains "en-GB" or similar
language;

// Set Globalize to the current culture driven by the meta tag (if any)
if (currentCulture) {
language = (currentCulture in $.fn.datepicker.dates)
? currentCulture //a language exists which looks like "zh-CN" so we'll use it
: currentCulture.split("-")[0]; //we'll try for a language that looks like "de" and use it if it exists (otherwise it will fall back to the default)
}

//Initialise any date pickers
$('.datepicker').datepicker({ language: language });