Hi,

  My problem can be shortly described by this picture: 
http://jm406.free.fr/capture3.jpg

So as a plone product developper i have try to understand why the name of the 
field is not translated, or where i have to translate it. Let me show you my 
content type.

ATM, i have a custom content types called 'Software'. This has been code in an 
egg called tranquilit.content.

Here is the content class:

# coding=utf-8
from zope.interface import implements
from tranquilit.content import config
from tranquilit.content import TranquilitContentMessageFactory as _
from tranquilit.content import interfaces as tranquilinterfaces
from Products.Archetypes import atapi
from Products.ATContentTypes.content import folder
from Products.ATContentTypes.content.schemata import finalizeATCTSchema
from Products.CMFPlone.interfaces import INonStructuralFolder

SoftwareSchema = folder.ATFolderSchema.copy()
SoftwareSchema['title'].storage = atapi.AnnotationStorage()
SoftwareSchema['title'].widget.label = _(u"Software_Function_name_label", 
default="Name")
SoftwareSchema['title'].widget.description = None
finalizeATCTSchema(SoftwareSchema, folderish=True, moveDiscussion=False)
SoftwareSchema['description'].schemata = 'default'
SoftwareSchema['description'].isMetadata = 0

class SoftwareContent(folder.ATFolder):
    """SoftwareContent description"""
    implements(tranquilinterfaces.ISoftwareContent, INonStructuralFolder)
    portal_type = "Software Content" #or  _(u"Software Content") ? same results
    schema = SoftwareSchema
    _at_rename_after_creation = True

...

Next i have my po file:
transquilit-fr.po well compiled:
# JeanMichel FRANCOIS <[EMAIL PROTECTED]>, 2007.
msgid ""
msgstr ""
"Last-Translator: JeanMichel FRANCOIS <[EMAIL PROTECTED]>\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"POT-Creation-Date: Fri Oct 19 12:17:50 2007\n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
"Language-Team: Makina-Corpus <[EMAIL PROTECTED]>\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Generated-By: zope/app/translation_files/extract.py\n"

#: /content/software.py:134
msgid "Software_Function_name_label"
msgstr "Nom"

msgid "Software Content"
msgstr "Fiche logiciel"
....

First of all the page when you edit you content type display simply in french 
'Editer Software Content'. I have try to create a simple Product, and put as 
the old i18n way my Software Content msgid, the results is ok, i get 'Editer 
Fiche logicielle'

So the first bug with i18n i have is now fixed. The next one is a bit more 
hard. When i let the title field empty or the description field empty i have 
this: 
http://jm406.free.fr/capture3.jpg

fieldErrorBox is not well translated.

I have take a look at the way it s translated here is the code
Archetypes/Field.py line 349
security.declarePrivate('validate_required')
    def validate_required(self, instance, value, errors):
        if not value:
            label = self.widget.Label(instance)
            name = self.getName()
            error = _(u'error_required',
                      default=u'${name} is required, please correct.',
                      mapping={'name': label})
            error = translate(error, context=aq_get(instance, 'REQUEST'))
            errors[name] = error
            return error
        return None
...
    security.declarePublic('getName')
    def getName(self):
        """Return the name of this field as a string"""
        return self.__name__


Well,  self.__name__  ?

    def __init__(self, name=None, **kwargs):
        """
        Assign name to __name__. Add properties and passed-in
        keyword args to __dict__. Validate assigned validator(s).
        """
        DefaultLayerContainer.__init__(self)

        if name is None:
            global _field_count
            _field_count += 1
            name = 'field.%s' % _field_count

        self.__name__ = name

name seems to be  Software_Function_name_label, (not the name of the field but 
the widget) and is  nto translated. What i found very strange is the line
error = translate(error, context=aq_get(instance, 'REQUEST')), cause error is 
already the results of the msgfactory from the plone domain. 
Where comes from the pb ? How can i fix this ? please this is my last bug on 
this project (my first plone3 ;)


JeanMichel FRANCOIS
Makina-Corpus

_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to