pombreda / formalchemy

Automatically exported from code.google.com/p/formalchemy
MIT License
0 stars 0 forks source link

Language selection: fieldset.render(lang='fr') ignored #166

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create a fieldset with a date field
2. call fieldset.render(lang='fr')
3. the form uses English language (ie months)

I'm using FormAlchemy 1.4.1, SQLAlchemy 0.7.2, Plone 3.3.4, Python 2.4.6

With a bit of debug, I finally got it working by adding:
fieldset.mydatefield.set(html=[('lang', 'fr')])

Anyway I expect it's not the way it should work.

I noticed "DateFieldRenderer" uses "FieldRenderer.get_translator" to get the 
correct translation.
"FieldRenderer.get_translator" expects and argument 'lang' in kwargs.
The kwargs come from "AbstractField.render", this "render" method calls 
"AbstractField._get_render_opts"; "_get_render_opts" reads "render_opts" and 
"html_options" from the field.
"render_opts" (that I'd set using fs.mydatefield.set(options=....)) can't 
handle a 'lang' entry, but the "html_options" (that I'd set using 
fs.mydatefield.set(html=....)) accept the lang option.
Therefore "fieldset.mydatefield.set(html=[('lang', 'fr')])" seems to work, but 
I expect this to be a workaround 
(http://docs.formalchemy.org/formalchemy/internationalisation.html).

Original issue reported on code.google.com by m.celo...@gmail.com on 9 Sep 2011 at 9:12