jQuery: The Write Less, Do More JavaScript Library

Plugins/Calendar/Localization

From jQuery JavaScript Library

Jump to: navigation, search

« Back to Plugins/Calendar

This page explains how to create a localization for the jQuery Calendar plugin.

Localization

The calendar is designed to allow localizations to be easily created and used. Many localizations are already available and additional ones are welcomed.

The calendar plugin maintains a manager object, popUpCal, that lets you register new localizations. This object maintains an array of localization settings indexed by language, with '' accessing the default (English) version: popUpCal.regional['fr'].

A new localization should be created in a separate JavaScript file named jquery-calendar-<language>.js. Within a document.ready event it should add a new entry into the popUpCal.regional array, indexed by the language code, with the following attributes: clearText, closeText, prevText, nextText, currentText, dayNames, monthNames, and dateFormat.

It should then set these values as global defaults so that they are automatically applied when this JavaScript is loaded: popUpCal.setDefaults(popUpCal.regional['<language>']);.

If necessary, the default language, or any other, may be re-established via a similar mechanism: popUpCal.setDefaults(popUpCal.regional['']);. Or the localizations may be applied to a single instance of the calendar: $('selector').calendar(popUpCal.regional['<language>']);

The complete French localization is shown below and is available as jquery-calendar-fr.js.

/* French initialisation for the jQuery calendar extension. */
/* Written by Keith Wood (kbwood@iprimus.com.au). */
$(document).ready(function(){
	popUpCal.regional['fr'] = {clearText: 'Effacer', closeText: 'Fermer', 
		prevText: '<Préc', nextText: 'Proch>', currentText: 'En cours',
		dayNames: ['Di','Lu','Ma','Me','Je','Ve','Sa'],
		monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin',
		'Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
		dateFormat: 'DMY/'};
	popUpCal.setDefaults(popUpCal.regional['fr']);
});