Discussion:
[Erp5-dev] which translation function to use...
Mikolaj Antoszkiewicz
2007-12-13 13:24:26 UTC
Permalink
Hello,

what are pros and cons for using such translate function mapping:
N_ = lambda msg, **kw: Message('erp5_ui', msg, **kw)

vs. this one:
T_ = context.Base_translateString
(or object.Base_translateString in workflow scripts)

?

Mikolaj

P.S. I've seen both used across ERP5 scripts and code...
Jérome Perrin
2008-02-13 19:32:31 UTC
Permalink
Hello,
Post by Mikolaj Antoszkiewicz
Hello,
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.
Post by Mikolaj Antoszkiewicz
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

Loading...