Is it possible to translate dexterity content type field names using plone.app.multilingual or some other add-on? I have been able to translate field content, but not field names. For example, I have a content type Dish with a field Price. I would like to translate "Price" to, say, Lithuanian "Kaina" so that if I switch to Lithuanian, it displays "Kaina" instead of "Price".
plone.app.multlingual is to create translated content. It allows linking content in different languages-
Field names should be translated using po files. If you have defined your content-type using plone.supermodel schema files, you need to add i18n:translate tags to the field names. Then you need to run i18ndude to produce po files and translate the texts there
<field name="myfieldname" type="zope.schema.TextLine"> <title i18n:translate="">This is the title of the field</title> <description i18n:translate="">This is the description of the field</description> <required>False</required> <default></default> <readonly>False</readonly> </field>
If you have modelled your content-types using Interfaces, you need to pass the field names from the _ method and then run i18ndude to produce po files:
from zope.interface import Interface from my.addon import _ class MyContenttype(Interface): myfieldname = schema.TextLine( title=_(u'This is the field title'), description=_(u'This is the field description'), required=False, default=u'', readonly=False, )
I think that requires your __init__.py file to read something like :
# -*- coding: utf-8 -*- from zope.i18nmessageid import MessageFactory _ = MessageFactory('my.addon')
If you make your add-on with bobtemplates this is probably taken care of (someone correct me if I am wrong)
If you have your schemas at the filesystem, I 100% agree with @erral.
If you really need pure through-the-web (no filesystem) translations of labels/field names and so on, there is
https://pypi.org/project/collective.ttwpo/ which helps to manage PO-files w/o filesystem access.
How do I do this if my content types are defined through the web? I can add i18n:translate tags via XML editor, but how do I run i18ndude to produce the .po files? Documentation describes (very poorly) how to do this if I have a package. Does this mean I must have a package to do this?
Thank you for you answer, but this package has zero useful documentation. What is i18ndomain? At first I thought this was going to be my language, but it seems I have to add languages under a domain as locales. How do I name my locales? Do these names have to match locale names of plone.app.multilingual to not create a mess? Under domain management I have to upload a .po file. How do I generate it so I can translate stuff?
If your content-types are defined through-the-web, the approach I explained does not work.
collective.ttwpo targets users with background knowlegde about GNU Gettext and its usage in Plone, sorry for that, no offence.
i18ndomain is a namespace for your translation, to not mix messages between different addons/ Plone core. Give it a name like "mysite".
Manually create a po-file using the messages in your ttw xml code. You can also use a tool like poedit. Upload the po-file to ttwpo.
Now the labels should be translated.
(I never tried this, but it has to work, otherwise there is a bug in the translation mechanism of TTW types).
https://pypi.org/project/collective.themesitesetup/ still also let you load .po files but doesn't make creating them any easier either.