[Erp5-dev] New things about translation

Aurélien Calonne aurel at nexedi.com
Tue Mar 21 20:13:17 CET 2006


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



More information about the Erp5-dev mailing list