Skip to main content

Plone Localization

December 22, 2008
  • First off, in your product when setting labels and descriptions on content types, use PloneMessageFactory...
    from zope.i18nmessageid import MessageFactory
    _ = MessageFactory("product.name")
    
  • Also, use the message factory in zope schemas and any other chance you are setting something that has labels that will be shown on the site
  • easy_insall i18ndude
  • Add a "locales" directory in your product
  • In your product's zcml, register the localization with something like this...
    <configure
      xmlns="http://namespaces.zope.org/zope"
      xmlns:i18n="http://namespaces.zope.org/i18n"
      i18n_domain="collective.plonetruegallery"> 
    
        .......
        <i18n:registerTranslations directory="locales" />
        .......
    
    </configure>
  • You'll need a ".pot" file in the root of the locales directory.  This is when we use i18ndude(assume we're in the product).  This will look through your product and find any places where there can be language specific aspects.
    i18ndude rebuild-pot --pot locales/myproduct.pot --create myproduct .
  • Then create a sub-directory in the locales directory for your language.  Then create a "LC_MESSAGES" directory inside that.  In the end you're structure will look something like this,
    locales/fr/LC_MESSAGES
  • Now lets use i18ndude again to create a ".po" file for the language we just added support for.
    i18ndude sync --pot locales/myproduct.pot locales/*/LC_MESSAGES/myproduct.po
  • Then just add the language customizations in the myproduct.po file.