mirror of
https://github.com/wassname/fullcalendar.git
synced 2026-07-15 01:11:15 +08:00
72 lines
2.2 KiB
JavaScript
72 lines
2.2 KiB
JavaScript
|
|
//var langOptionHash = {}; // initialized in defaults.js
|
|
fc.langs = langOptionHash; // expose
|
|
|
|
|
|
// Initialize jQuery UI Datepicker translations while using some of the translations
|
|
// for our own purposes. Will set this as the default language for datepicker.
|
|
// Called from a translation file.
|
|
fc.datepickerLang = function(langCode, datepickerLangCode, options) {
|
|
var langOptions = langOptionHash[langCode];
|
|
|
|
// initialize FullCalendar's lang hash for this language
|
|
if (!langOptions) {
|
|
langOptions = langOptionHash[langCode] = {};
|
|
}
|
|
|
|
// merge certain Datepicker options into FullCalendar's options
|
|
mergeOptions(langOptions, {
|
|
isRTL: options.isRTL,
|
|
weekNumberTitle: options.weekHeader,
|
|
titleFormat: {
|
|
month: options.showMonthAfterYear ?
|
|
'YYYY[' + options.yearSuffix + '] MMMM' :
|
|
'MMMM YYYY[' + options.yearSuffix + ']'
|
|
},
|
|
defaultButtonText: {
|
|
// the translations sometimes wrongly contain HTML entities
|
|
prev: stripHtmlEntities(options.prevText),
|
|
next: stripHtmlEntities(options.nextText),
|
|
today: stripHtmlEntities(options.currentText)
|
|
}
|
|
});
|
|
|
|
// is jQuery UI Datepicker is on the page?
|
|
if ($.datepicker) {
|
|
|
|
// Register the language data.
|
|
// FullCalendar and MomentJS use language codes like "pt-br" but Datepicker
|
|
// does it like "pt-BR" or if it doesn't have the language, maybe just "pt".
|
|
// Make an alias so the language can be referenced either way.
|
|
$.datepicker.regional[datepickerLangCode] =
|
|
$.datepicker.regional[langCode] = // alias
|
|
options;
|
|
|
|
// Alias 'en' to the default language data. Do this every time.
|
|
$.datepicker.regional.en = $.datepicker.regional[''];
|
|
|
|
// Set as Datepicker's global defaults.
|
|
$.datepicker.setDefaults(options);
|
|
}
|
|
};
|
|
|
|
|
|
// Sets FullCalendar-specific translations. Also sets the language as the global default.
|
|
// Called from a translation file.
|
|
fc.lang = function(langCode, options) {
|
|
var langOptions;
|
|
|
|
if (options) {
|
|
langOptions = langOptionHash[langCode];
|
|
|
|
// initialize the hash for this language
|
|
if (!langOptions) {
|
|
langOptions = langOptionHash[langCode] = {};
|
|
}
|
|
|
|
mergeOptions(langOptions, options || {});
|
|
}
|
|
|
|
// set it as the default language for FullCalendar
|
|
defaults.lang = langCode;
|
|
}; |