[Erp5-dev] which translation function to use...
Jérome Perrin
jerome at nexedi.com
Wed Feb 13 20:32:31 CET 2008
Hello,
Mikolaj Antoszkiewicz a écrit :
> Hello,
>
> what are pros and cons for using such translate function mapping:
> N_ = lambda msg, **kw: Message('erp5_ui', msg, **kw)
This creates an instance of Message, which is a class translated when
displayed. It can be stored in the database, and will be translated each
time it is displayed.
The primary use case is to store messages from ValidationFailed in
workflow history, and have this message translated in user locale when
the user sees the message, instead of storing in workflow history the
message translated in the language of the user who gets the
ValidationFailed.
This can also keep a mapping, for example you can store a message like this:
Message('erp5_ui', 'Invalid Line ${line_number}',
mapping=dict(line_number=line.getNumber())))
again, this will be translated when displayed.
> vs. this one:
> T_ = context.Base_translateString
> (or object.Base_translateString in workflow scripts)
This just translates a string through Localizer. We created this not to
hardcode "Localizer" everywhere. It was here before Message class, so we
keep it for compatibility.
Jérome
More information about the Erp5-dev
mailing list