Use lazy_pass_to_ugettext for forms
|Reported by:||Elrond||Owned by:||aditi|
|Cc:||Christopher Allan Webber||Parent Tickets:|
(This might be a dupes, but I could not find it.)
To translate forms, we currently go the following route:
- Mark strings as translatable (only mark, do nothing else)
- wtforms keeps them for us
- Our field rendering tools render the complete field nearly completely ba hand to be able to translate it there. Using standard translation tools there.
This works, mostly. It does not work to translate elements of a select box, for example a title like "- Select Collection -". Because we only mark it, but we're not using our translation tools in the rendering. We could go for rendering that part by hand also.
BUT: wtforms recommends something else:
lazy_pass_to_ugettext()to mark and create a autotranslating object. This feels like a string, but really becomes a translated string, when it is forced to a real string.
- wtforms keeps this thing as a normal object around.
- When rendering it, wtforms will force it to a string as late as possible, so that translations can take effect.
So the first idea is to mark strings using
lazy_pass_to_ugettext() and just disable the translation in our rendering tools (just remove the
_()!) and see, how it works out.
Old in any
from mediagoblin.tools.translate import fake_ugettext_passthrough as _
from mediagoblin.tools.translate import lazy_pass_to_ugettext as _
Change History (6)
by , 11 years ago