[Zope] a patch for the calendar tag 0.9.10

2000-06-04 Thread Jerome ALET

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 eacute;
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


--- 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():



Re: [Zope] a patch for the calendar tag 0.9.10

2000-06-04 Thread Jerome ALET

Sorry, I've created a new patch, because in my previous one I've
forgotten to correct the day mode too.

The problem happens in day mode as well as in week mode, even
if the week wasn't between two months.

Sorry for the incoveninence, you'll find the new patch attached 
to this message.

bye,
Jerome Alet

On Sun, Jun 04, 2000 at 11:20:34AM +0200, Jerome ALET wrote:
 here's a patch for the Calendar 0.9.10 product.
 ...
 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.


--- CalendarTag.py.orig Sun Jun  4 11:09:54 2000
+++ CalendarTag.py  Sun Jun  4 13:18:40 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()
 
@@ -226,15 +242,15 @@
 v['next_url_'] = self.linkDate_(d, mode)
 else:
 if self.mode == 'day':
-monthname = v['monthnames'][date.month() - 1][:3]
+monthname = self.__cutmonthname(v['monthnames'][date.month() - 1], 3)
 left = '%s %d, %d' % (monthname, date.day(), date.year())
 v['day_img_'] = 'sday'
 v['daynames'] = None
 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():