[Zope] The date in Dutch
Steve Alexander
steve@cat-box.net
Fri, 18 Aug 2000 10:30:45 +0100
Sent again -- here's a slightly more compact version, that avoids
declaring a separate class to hold the expressions in.
Michel Houben wrote:
> How can I fix the date in Dutch, for example Donderdag 17 Augustus 2000
> instead of Thursday 17 August 2000. I hope someone can solve this problem.
I don't know any Dutch.
However, here's an external method that will convert the months and days
of the week in a string from English to German.
There are probably better names for the variables and such, so don't
take this as as example of clear maintainable programming :)
It ought be be pretty efficient.
Assuming you call the external method D_date, use something like this:
<dtml-var "D_date('October February July, Tuesday, 23 March 2000')">
----
import re
# you can remove lines where the words are the same in both languages
replacements={
'Monday':'Montag',
'Tuesday':'Dienstag',
'Wednesday':'Mittwoch',
'Thursday':'Donnerstag',
'Friday':'Freitag',
'Saturday':'Samstag',
'Sunday':'Sonntag',
'January':'Januar',
'February':'Februar',
'March':'März',
'April':'April',
'May':'Mai',
'June':'Juni',
'July':'Juli',
'August':'Augustus',
'September':'September',
'October':'Oktober',
'November':'November',
'December':'Dezember'
}
replace_regexes=[]
for e,d in replacements.items():
replace_regexes.append(
eval("lambda x: re.compile('%s').sub('%s', x)" % (e, d)))
def D_date(datestring):
return reduce(lambda x,y: y(x), replace_regexes, datestring)
----
--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net