# HG changeset patch # User Katia Saurfelt # Date 1330422398 -3600 # Node ID 2d660890d3e8036b1a7e1e49a8f30d4fbbbdf7eb # Parent 8b0146e31baaa7650c3c49b666c8c39226c029ca [js] translate calendar in french (closes #2167866) diff -r 8b0146e31baa -r 2d660890d3e8 web/data/fullcalendar.locale.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/data/fullcalendar.locale.js Tue Feb 28 10:46:38 2012 +0100 @@ -0,0 +1,35 @@ +jQuery(function($){ + $.fullCalendar.regional = function(lng, options){ + var defaults = {'fr' : { + monthNames: + ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'], + monthNamesShort: ['janv.','févr.','mars','avr.','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'], + titleFormat: { + month: 'MMMM yyyy', // ex : Janvier 2010 + week: "d[ MMMM][ yyyy]{ - d MMMM yyyy}", // ex : 10 — 16 Janvier 2010, + day: 'dddd d MMMM yyyy' // ex : Jeudi 14 Janvier 2010 + }, + columnFormat: {'month': 'dddd', + 'agendaWeek': 'dddd dd/M/yyyy', + 'agendaDay': 'dddd dd/M/yyyy'}, + axisFormat: 'H:mm', + timeFormat: { + '': 'H:mm', + agenda: 'H:mm{ - H:mm}'}, + allDayText: 'journée', + axisFormat: 'H:mm', + buttonText: { + today: "aujourd'hui", + month: 'mois', + week: 'semaine', + day: 'jour' + } + }}; + if(lng in defaults){ + return $.extend({}, defaults[lng], options); + } + else {return options;}; + }; +}); \ No newline at end of file diff -r 8b0146e31baa -r 2d660890d3e8 web/views/calendar.py --- a/web/views/calendar.py Mon Feb 13 17:44:44 2012 +0100 +++ b/web/views/calendar.py Tue Feb 28 10:46:38 2012 +0100 @@ -178,22 +178,15 @@ fullcalendar_options = { 'firstDay': 1, + 'firstHour': 8, + 'defaultView': 'month', + 'editable': True, 'header': {'left': 'prev,next today', 'center': 'title', 'right': 'month,agendaWeek,agendaDay', }, - 'editable': True, - 'defaultView': 'month', - 'timeFormat': {'month': '', - '': 'H:mm'}, - 'firstHour': 8, - 'axisFormat': 'H:mm', - 'columnFormat': {'month': 'dddd', - 'agendaWeek': 'dddd yyyy/M/dd', - 'agendaDay': 'dddd yyyy/M/dd'} } - def call(self): self._cw.demote_to_html() self._cw.add_css(('fullcalendar.css', 'cubicweb.calendar.css')) @@ -203,17 +196,12 @@ # write calendar div to load jquery fullcalendar object self.w(u'
' % self.calendar_id) - def add_onload(self): - fullcalendar_options = self.fullcalendar_options.copy() - fullcalendar_options['events'] = self.get_events() - fullcalendar_options['buttonText'] = {'today': self._cw._('today'), - 'month': self._cw._('month'), - 'week': self._cw._('week'), - 'day': self._cw._('day')} + # i18n + self._cw.add_js('fullcalendar.locale.js') # js callback to add a tooltip and to put html in event's title js = """ - var options = %s; + var options = $.fullCalendar.regional('%s', %s); options.eventRender = function(event, $element) { // add a tooltip for each event var div = '
'+ event.description+ '
'; @@ -223,7 +211,7 @@ }; $("#%s").fullCalendar(options); """ #" - self._cw.add_onload(js % (json_dumps(fullcalendar_options), self.calendar_id)) + self._cw.add_onload(js % (self._cw.lang, json_dumps(self.fullcalendar_options), self.calendar_id)) def get_events(self):