Discussion:
[Erp5-dev] New things about translation
Aurélien Calonne
2006-03-21 19:13:17 UTC
Permalink
Hello,

Some weeks ago I implemented new stuff about translation, here they are :

- based on this discussion in the wiki :
http://wiki.erp5.org/Discussion/TranslationPolicy, I extended property sheet
so that we can specify if a property is translatable or not and specify its
translation domain. So for example the property title in SimpleItem.py :
_properties = (
{ 'id' : 'title',
'description' : '',
'type' : 'string',
'default' : '',
'mode' : 'w',
'translatable': '1',
'translation_domain' : 'erp5_content',
},
...
If the property is set to translatable, accesors like getTranslatedProperty,
getPropertyTranslationDomain and setPropertTranslationDomain are created.

Translation domain defined in the property sheet can be overridden. The first
way is to use the tab 'Translate' on the portal type and to select the
translation domain you want, an other way is to define a python script named
as PortalType_getPropertyTranslationDomain and to return the domain from this
script.

The order in which the translation domain is get is the following : first look
if a script redefine it, then look on portal type, then look at the property
sheet. At the end if no translation domain is found, no translation is
performed.

- for category, a new accessor as also been added so that now you can call
getCategoryTranslatedTitle

- last think I added is a new class, named Message which can be used to stored
a message, its domain and its mapping.
One used of this class is for workflow script when raising
ValidationFailed. now you can create a Message instance wich deal with
mapping and a specific domain, and raised ValidationFailed with this instance
like this : raise ValidationFailed, (msg,)
Thus the message instance will be register in the workflow history and will be
translated in the right way when display to the user
--
Aur?lien
Loading...