Hi Maurits,
thanks for pointing this out.
Indeed I oversaw first the atschema local command that did two things:
Adding the correct underscore (MessageFactory) entry in the
content .py file. This is not present when you only run
paster addcontent mytype
Because the at field skeleton injected from paster does not reflect
the approach you describe later down, I started to edit the schema by
hand.
Without running
paster addcontent atschema
You get a name error for "_". It is quite difficult to search in
google for something related to underscore and or "_(u".
Finally I stumbled over a hint in Stackoverflow pointing to Django and
figure out the approach documented in the "__init__.py" file of the
inner namespace of the package.
Do you know a reason why the line below the comment in the type schema
in the content folder is omitted on initial creation of the type:
file ../content/*.py
##################################
...
# -*- Message Factory Imported Here -*-
from package.mypackage import viewsMessageFactory as _ # this is only
present after creating the first field!
##################################
Hope this forum entry helps to look up this
Three things:
1. Something next to the comment in the contenttype ../content/*.py
file should be more verbose like:
##################################
# Avoid adding initial field skeletons by hand, use atschema local
command instead.
# If not: On 'Name error: "_" is undefined' , uncomment the following
line:
# from {package.mypackage} import viewsMessageFactory as _
# {package.mypackage} must be replaced by paster on creation.
##################################
2. The skeleton you provided below, should be present in the schema
generated by paster addcontent atschema.
3. The import of the atapi module should be already prepared with the
safe 4 lines for LinguaPlone. Or the paster script should have an
option to default to this (even dexterity is coming up, but as I know
it is still not i18n aware).
I am looking forward to test the new syntax with i18ndude.
Thank you very much!
Armin
Keywords: archetypes, zopeskel, paster, addcontent, atschema, Default
Message,
Am 15.08.2011 um 10:26 schrieb Maurits van Rees:
Op 14-08-11 13:00, Armin Stroß-Radschinski schreef:
Examples
================
This is one of my Archetype fields schema in one of my content
types files:
~/instances/MySite/src/mytranslated.package/mytranslated/package/
content/tour.py
The schema file:
-------------------------------------------------
....
atapi.StringField('productCode',
required=False,
searchable=True,
languageIndependent=False,
storage=atapi.AnnotationStorage(),
widget
=
atapi
.StringWidget(label_msgid='MyTranslationDomain_label_productCode',
label=_(u"Product Code"),
i18n_domain='MyTranslationDomain',
description_msgid='MyTranslationDomain_help_productCode',
description=_(u"A short unique code to identify our products"),
),
),
Here you are combining two ways of doing i18n: the archetypes
specific way with label_msgid and i18n_domain and the general way of
using the underscore (MessageFactory). I recommend using only the
new way. So that would be like this:
widget=atapi.StringWidget(label_msgid='',
label=_(u'MyTranslationDomain_label_productCode',
default=u"Product Code"),
description=_(u'MyTranslationDomain_help_productCode',
default=u"A short unique code to identify our
products"),
),
--
Maurits van Rees
Web App Programmer at Zest Software: http://zestsoftware.nl
Personal website: http://maurits.vanrees.org/
_______________________________________________
Product-Developers mailing list
[email protected]
https://lists.plone.org/mailman/listinfo/plone-product-developers
--
Armin Carl Stroß-Radschinski, Dipl. Designer
acsr industrialdesign, Landgrafenstraße 32, 53842 Troisdorf, Germany
Telefon +49 (0) 22 41 / 94 69 94, FAX +49 (0) 22 41 / 94 69 96
eMail [email protected] - http://www.acsr.de
UST. ID Nr: DE154092803 (EU VAT ID)
_______________________________________________
Product-Developers mailing list
[email protected]
https://lists.plone.org/mailman/listinfo/plone-product-developers