Skip to content

Instantly share code, notes, and snippets.

@arshaw
Created September 16, 2011 06:42
Show Gist options
  • Save arshaw/1221376 to your computer and use it in GitHub Desktop.
Save arshaw/1221376 to your computer and use it in GitHub Desktop.
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"
@1mehdifaraji
Copy link

Thanks for the amazing library just one question how can I change the locale to MiddleEastern countries like turkey and iran ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment