Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
XDate: Changing the Locale
// You can add new locales by adding a new object to the `XDate.locales` hash.
// You can change the default locale by changing `XDate.defaultLocale`.
XDate.locales['fr'] = {
monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
monthNamesShort: ['Janv.','Févr.','Mars','Avril','Mai','Juin','Juil.','Août','Sept.','Oct.','Nov.','Déc.'],
dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
dayNamesShort: ['Dim.','Lun.','Mar.','Mer.','Jeu.','Ven.','Sam.']
new XDate().toString('d MMMM, yyyy', 'fr'); // "24 Octobre, 2011"
// or, you set the default locale...
XDate.defaultLocale = 'fr';
new XDate().toString('d MMMM, yyyy'); // "24 Octobre, 2011"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment