Entering multilanguage data in Zope

26 November 2006   0 comments  

Mind That Age!

This blog post is 12 years old! Most likely, its content is outdated. Especially if it's technical.

Powered by Fusion×

Zope is really great with it's publisher transform things that automatically cast HTTP GET or HTTP POST variables as proper python variables on the fly. I needed a form that asks for a Title and Description in multiple languages. The result I wanted passed into the saving method was variables like this:

>>> titles
{'en': u'London', 'sv': u'Stockholm'}
>>> descriptions
{'en': u'Capital', 'sv': u'Huvudstad'}

How did I write that form? Easy, here's the code:

<b>Title</b><br />
Svenska: <input name="title.sv:record" /><br />
English: <input name="title.en:record" /><br />
Svenska: <input name="description.sv:record" /><br />
English: <input name="description.en:record" /><br />

And lastly, to get the unicoding right, you have to add the following so that the variable values are sent as iso-8859-1 encoded unicode strings:

<b>Title</b><br />
Svenska: <input name="title.sv:latin1:ustring:record" /><br />
English: <input name="title.en:latin1:ustring:record" /><br />
Svenska: <input name="description.sv:latin1:ustring:record" /><br />
English: <input name="description.en:latin1:ustring:record" /><br />

Zope takes care of the rest and you can just sit back and enjoy the productivity.


Thank you for posting a comment

Your email will never ever be published

Related posts

Bloggers not responsible for comment? 23 November 2006
MUnderscorePatch - tired of typing manage_main? 29 November 2006
Related by Keyword:
Lesson learned: Unicodifying request variables in Zope 16 April 2009
Playing with filestream_iterator 30 May 2007
Sending HTML emails in Zope 26 October 2006
Related by Text:
Button tag in bloody Internet Explorer 09 August 2005
slim, a new free web service for white space optimisation 25 July 2006
Lesson learned: Unicodifying request variables in Zope 16 April 2009
What stumped me about AngularJS 12 May 2013
Labels in HTML forms 26 January 2004