Product (skin) localization
Original article can be found here: http://www.len.ro/work/cms/custom-product-skin-localization
With a plone site you can do a lot of localization using the linguaPlone product. This is a great tool even if it still has some problems with the localization of folder default pages (folders which have a page as custom view). But in a custom skin there are also elements which need some localization. In my case it was the left side portlet which needed romanian and english localization.
Your product skin structure
In order to add localization to your plone product first you have to add an i18n directory to the product root. Don't worry you will not need to change the config.py script.
config.py Extensions __init__.py README.txt tests
config.pyc HISTORY.txt __init__.pyc refresh.txt version.txt
CVS i18n LICENSE.txt skins
Localization of your template
You can then use the i18n:... tags as described in the plone book internationalization section
<div class="prezentarePortlet" i18n:translate="prezentare_string">
Schedule a free presentation for SOLIS
There are 2 elements here:
i18n:domain="solis" which represent a localization domain which is in fact a translation group of files. By default plone uses the "plone" domain but this means you whould have to modify the ./PloneTranslations/i18n/plone_xx.po files which is not nice as your product must be self contained. As such I defined a domain specially for this product. This will correspond to a solis.pot and some solis_xx.po files in the created i18n directory.
- the i18n:translate="prezentare_string" defines a translation key or id. If the translation key is found in the solis domain it will be used to replace the div content.
The localization tool
You can create the files localization files by hand or you can use the i18ndude tool. You can download the tool from the plone site as an .egg package. On debian based distros you can install the egg with these commands:
#install the easy_install toolsThen you can create the localization file with a command similar to
apt-get install python-setuptools
#install the egg
i18ndude rebuild-pot --pot solis.pot --create solis ../skins/solistheme_templates/prezentarePortlet.pt
The localization files
Now all you need is to copy the solis.pot to the solis_xx.po file according to your localization and modify the entries inside (including the header). xx is of course your locale short code (en and ro in my case).
The file format is very simple, key (msgid) and value (msgstr) separated on different lines:
msgstr "this is the text"
If everything was ok you should see your translation files after restart in the zope Control Panel > Translation manager page and you should see the template change according to the linguaPlone language along with your other content.