Paste number 32285: Diff for date translation

Index of paste annotations: 1

Paste number 32285: Diff for date translation
Pasted by: jfroche
When:14 years, 9 months ago
Share:Tweet this! | http://paste.lisp.org/+OWT
Channel:#schooltool
Paste contents:
Raw Source | XML | Display As
[jfroche@blade2]/usr/lib/schooltool-vauban/src/schooltool/app -> svn diff                                                                                                  16:25
Index: browser/cal.py
===================================================================
--- browser/cal.py      (revision 6518)
+++ browser/cal.py      (working copy)
@@ -89,6 +89,7 @@
 from schooltool.person.interfaces import IPerson, IPersonPreferences
 from schooltool.person.interfaces import vocabulary
 from schooltool.resource.interfaces import IResource
+from schooltool.skin.dateformatter import DateFormatterFullView
 from schooltool.timetable.interfaces import ICompositeTimetables
 from schooltool.term.term import getTermForDate
 
@@ -375,10 +376,6 @@
         self.date = date
         self.events = events
         day_of_week = day_of_week_names[date.weekday()]
-        self.title = _('${day_of_week}, ${date}',
-                       mapping = {'day_of_week': day_of_week,
-                                  'date': date.strftime('%Y-%m-%d')})
-        # XXX Shouldn't we use a i18n formatter for the date in the title?
 
     def __cmp__(self, other):
         return cmp(self.date, other.date)
@@ -427,9 +424,12 @@
             return url + '.pdf'
 
     def dayTitle(self, day):
-        dayformat = '%A, ' + self.dateformat
-        return u'' + day.strftime(dayformat)
+        formatter = DateFormatterFullView(day, self.request)
+        return formatter()
 
+        #dayformat = '%A, ' + self.dateformat
+        #return u'' + day.strftime(dayformat)
+
     __url = None
 
     def calURL(self, cal_type, cursor=None):
@@ -859,9 +859,11 @@
     def title(self):
         month_name_msgid = month_names[self.cursor.month]
         month_name = translate(month_name_msgid, context=self.request)
-        msg = _('${month}, ${year} (week ${week})',
+        week_title = translate(_("week"), context=self.request)
+        msg = _('${month}, ${year} (${week_title} ${week})',
                 mapping = {'month': month_name,
                            'year': self.cursor.year,
+                           'week_title': week_title,
                            'week': self.cursor.isocalendar()[1]})
         return msg
 
Index: browser/templates/cal_weekly.pt
===================================================================
--- browser/templates/cal_weekly.pt     (revision 6517)
+++ browser/templates/cal_weekly.pt     (working copy)
@@ -11,7 +11,7 @@
             tal:attributes="class python:' '.join(filter(None, ['day-title',
                                                    start and 'first' or '',
                                                    day.today()]))">
-          <a tal:content="day/title" i18n:translate=""
+          <a tal:content="day/date/@@fullDate" i18n:translate=""
              tal:attributes="href python:view.calURL('daily', day.date)" />
         </th>
       </tal:loop>
@@ -27,7 +27,7 @@
                    class python:start and 'first' or '';
                    style string:background: ${event/color1};;
                                 border-color: ${event/color2};
-                   title event/title;
+                   title event/date/@@fullDate;
                    href event/editLink">
               <span tal:content="event/shortTitle"/>
               <tal:if condition="not:event/allday">

Annotations for this paste:

Annotation number 1: Reviewed the code a bit
Pasted by: ignas
When:14 years, 9 months ago
Share:Tweet this! | http://paste.lisp.org/+OWT/1
Paste contents:
Raw Source | Display As
+        formatter = DateFormatterFullView(day, self.request)
+        return formatter()
 
+        #dayformat = '%A, ' + self.dateformat
+        #return u'' + day.strftime(dayformat)
+

You should lookup a view in here instead of hardcoding it and adding a dependency to schooltool.skin


     __url = None
 
     def calURL(self, cal_type, cursor=None):
@@ -859,9 +859,11 @@
     def title(self):
         month_name_msgid = month_names[self.cursor.month]
         month_name = translate(month_name_msgid, context=self.request)
-        msg = _('${month}, ${year} (week ${week})',
+        week_title = translate(_("week"), context=self.request)
+        msg = _('${month}, ${year} (${week_title} ${week})',
                 mapping = {'month': month_name,
                            'year': self.cursor.year,
+                           'week_title': week_title,
                            'week': self.cursor.isocalendar()[1]})

Nope, wrong, the _('${month}, ${year} (week ${week})' is a translatable string which means that it will get translated.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.