[Zope] a patch for the calendar tag 0.9.10
Jerome ALET
Jerome.Alet@unice.fr
Sun, 4 Jun 2000 11:20:34 +0200
--opJtzjQTFsWo+cga
Content-Type: text/plain; charset=us-ascii
Hi there,
here's a patch for the Calendar 0.9.10 product.
This version allows people to define their own
day or month names instead of the default
english names.
This is very useful if you want to setup a
web calendar in another language than English.
In French, some month names contain accented letters,
represented in HTML by character entities like é
for example.
The Calendar product doesn't cut the month names
correctly in regard to these entities, especially
in week mode when a week was between two months.
Here's a patch to correct the problem.
hope this helps.
bye,
Jerome Alet
--opJtzjQTFsWo+cga
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="Calendar-0.9.10.patch"
--- CalendarTag.py.orig Sun Jun 4 11:09:54 2000
+++ CalendarTag.py Sun Jun 4 11:08:43 2000
@@ -114,6 +114,22 @@
self.week_sday = int(weekdays[0])
self.week_ndays = int(weekdays[1])
+ def __cutmonthname(self, name, length) :
+ """Cuts the month name at length characters, counting
+ character entities for only one character"""
+ entityfound = 0
+ for i in range(len(name)) :
+ if name[i] == '&' :
+ entityfound = 1
+ elif name[i] == ';' :
+ entityfound = 0
+
+ if not entityfound :
+ length = length - 1
+ if not length :
+ break
+ return name[:i + 1]
+
def render(self, md):
## time_start = time()
@@ -233,8 +249,8 @@
elif self.mode == 'week':
sdow = date - date.dow()
edow = sdow + 6
- smonthname = v['monthnames'][sdow.month() - 1][:3]
- emonthname = v['monthnames'][edow.month() - 1][:3]
+ smonthname = self.__cutmonthname(v['monthnames'][sdow.month() - 1], 3)
+ emonthname = self.__cutmonthname(v['monthnames'][edow.month() - 1], 3)
left = '%s %d' % (emonthname, edow.year())
if sdow.aMonth() != edow.aMonth():
--opJtzjQTFsWo+cga--