Plone i18n, LinguaPlone

3,162 views

Published on

History intro, Packages which influence i18n, How to translate your package

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,162
On SlideShare
0
From Embeds
0
Number of Embeds
41
Actions
Shares
0
Downloads
23
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Plone i18n, LinguaPlone

  1. 1. <ul><li>Plone i18n, LinguaPlone </li></ul><ul><ul><li>Vitaliy Podoba, Developer </li></ul></ul><ul><ul><li>© Quintagroup, 2008 </li></ul></ul>
  2. 2. Zope/Plone i18n
  3. 3. Table of contents <ul><li>History intro </li></ul><ul><li>Packages which influence i18n </li></ul><ul><li>Howto translate your package </li></ul><ul><li>Questions/Answers </li></ul>
  4. 4. History intro <ul><li>No i18n </li></ul><ul><li>ZBabel </li></ul><ul><li>Localizer </li></ul><ul><li>PlacelessTranslationService </li></ul><ul><li>I18NLayer </li></ul><ul><li>I18NFolder </li></ul><ul><li>PloneLanguageTool </li></ul><ul><li>LinguaPlone </li></ul>
  5. 5. i18n packages <ul><li>zope.i18n, zope.i18nmessageid </li></ul><ul><li>zope.app.i18n </li></ul><ul><li>Five </li></ul><ul><li>PlacelessTranslationservice </li></ul><ul><li>plone.i18n </li></ul><ul><li>plone.app.i18n </li></ul><ul><li>PloneTranslations </li></ul><ul><li>PloneLanguageTool </li></ul><ul><li>CMPPlone </li></ul>
  6. 6. Addon translation <ul><li>Keep your code translatable: </li></ul><ul><li>Addon translation domain </li></ul><ul><li>Page Template translation </li></ul><ul><li>Python code translation </li></ul><ul><li>GS profile translation </li></ul><ul><li>Translation files </li></ul>
  7. 7. Translation domain <ul><li>from zope.i18nmessageid import MessageFactory </li></ul><ul><li>PloneMessageFactory = MessageFactory('plone') </li></ul>
  8. 8. Page Template translation <ul><li><html ... </li></ul><ul><li>xmlns:i18n=&quot; http://xml.zope.org/namespaces/i18n &quot; </li></ul><ul><li>i18n:domain=&quot;plone&quot;> </li></ul><ul><li>... </li></ul><ul><li><div i18n:domain=&quot;some.other.domain&quot;>...</div> </li></ul><ul><li>... </li></ul><ul><li></html> </li></ul>
  9. 9. <ul><li><p i18n:translate=&quot;msg_id&quot;>Welcome to Plone.</p> </li></ul><ul><li><p i18n:translate=&quot;&quot;>Welcome to Plone.</p> </li></ul>
  10. 10. <ul><li><img src=&quot;plone.gif&quot; </li></ul><ul><li>alt=&quot;Plone Icon&quot; </li></ul><ul><li>title=&quot;Plone Icon Title&quot; </li></ul><ul><li>i18n:attributes=&quot;alt title&quot;> </li></ul><ul><li><img src=&quot;plone.gif&quot; </li></ul><ul><li>alt=&quot;Plone Icon&quot; </li></ul><ul><li>title=&quot;Plone Icon Title&quot; </li></ul><ul><li>i18n:attributes=&quot;alt plone-icon; </li></ul><ul><li>title plone-icon-title&quot;> </li></ul>
  11. 11. <ul><li><p i18n:translate=&quot;&quot;>There have been over </li></ul><ul><li><span tal:content=&quot;here/download_count&quot; </li></ul><ul><li>i18n:name=&quot;count&quot;>100,000</span> </li></ul><ul><li>downloads of Plone. </li></ul><ul><li></p> </li></ul>There have been ${count} downloads of Plone.
  12. 12. Python code translation <ul><li>from Products.CMFPlone import PloneMessageFactory as _ </li></ul><ul><li>return _(u&quot;Welcome to Plone&quot;) </li></ul><ul><li>from Products.CMFPlone import PloneMessageFactory as _ </li></ul><ul><li>return _(u&quot;welcome_to_plone&quot;, </li></ul><ul><li>default=&quot;Welcome to Plone, ${date}&quot;, </li></ul><ul><li>mapping={'date':'2008-08-08'}) </li></ul>
  13. 13. <ul><li>ts = getToolByName(context, 'translation_service') </li></ul><ul><li>return ts.translate('domain', </li></ul><ul><li>'msgid', </li></ul><ul><li>context, </li></ul><ul><li>{'date':'2008-08-08'}, </li></ul><ul><li>target_language='en', </li></ul><ul><li>default='Default message') </li></ul>
  14. 14. GS Profile Translation <ul><li>See Page Template Translation section </li></ul>
  15. 15. Translation files
  16. 16. Translation Tools <ul><ul><li>I18ndude </li></ul></ul><ul><ul><li>i18nextract.py </li></ul></ul><ul><ul><li>PloneTranslations utils </li></ul></ul><ul><ul><li>poEdit </li></ul></ul>
  17. 17. <ul><li>i18ndude rebuild-pot --pot locales/mydomain.pot --create mydomain . </li></ul><ul><li>i18ndude sync --pot locales/mydomain.pot locales/*/LC_MESSAGES/mydomain.po </li></ul>i18ndude
  18. 18. <ul><li>#. Default: &quot;Site News&quot; </li></ul><ul><li>msgid &quot;news-description&quot; </li></ul><ul><li>msgstr &quot;&quot; </li></ul><ul><li>#. Default: &quot;Events&quot; </li></ul><ul><li>msgid &quot;events-title&quot; </li></ul><ul><li>msgstr &quot;&quot; </li></ul>POT Example
  19. 19. Compile po files <ul><li># Compile po files </li></ul><ul><li>for lang in $(find locales -mindepth 1 -maxdepth 1 -type d); do </li></ul><ul><li>if test -d $lang/LC_MESSAGES; then </li></ul><ul><li>msgfmt -o $lang/LC_MESSAGES/${PRODUCTNAME}.mo $lang/LC_MESSAGES/${PRODUCTNAME}.po </li></ul><ul><li>fi </li></ul><ul><li>done </li></ul>
  20. 20. Register translation <ul><li><configure </li></ul><ul><li>xmlns:i18n=&quot;http://namespaces.zope.org/i18n&quot;> </li></ul><ul><li><i18n:registerTranslations directory=&quot;locales&quot; /> </li></ul><ul><li></configure> </li></ul>
  21. 21. Questions/Answers
  22. 22. LinguaPlone
  23. 23. Table of contents <ul><li>LinguaPlone Features </li></ul><ul><li>UI </li></ul><ul><li>LinguaPlone Internals </li></ul><ul><li>Questions/Answers </li></ul>
  24. 24. Features <ul><li>Totally transparent, install-and-go </li></ul><ul><li>Each translation is a discrete object, and can be workflowed individually </li></ul><ul><li>Translations are kept track of using AT references </li></ul><ul><li>Even if you uninstall LinguaPlone after adding multilingual content, all your content will be intact and will work as separate objects </li></ul>
  25. 25. Features <ul><li>Supporting multilingual capabilities is a 4 (!) line addition to your Archetypes class </li></ul><ul><li>Fully integrated with ATContentTypes, so the basic content types are translatable </li></ul><ul><li>Supports language-independent fields </li></ul><ul><li>Uses the notion of Canonical versions </li></ul><ul><li>LinguaPlone doesn't require a particular hierarchy of content </li></ul>
  26. 26. UI <ul><li>Languages Control Panel </li></ul><ul><li>'Translate into' pulldown menu </li></ul><ul><li>Translation Form </li></ul><ul><li>Manage Translations Form </li></ul><ul><li>Language Selector Viewlet </li></ul><ul><li>Language Portlet </li></ul>
  27. 27. Languages Configlet
  28. 28. Translate into menu
  29. 29. Translation Form
  30. 30. Translation Form
  31. 31. Manage Translations Form
  32. 32. Manage Translations Form
  33. 33. Language Selector Viewlet
  34. 34. Language Portlet
  35. 35. Internals <ul><li>Patches: publisher, catalog, kupu </li></ul><ul><li>LanguageIndex: Language </li></ul><ul><li>languageIndependent=True </li></ul><ul><li>AT references: translationOf </li></ul><ul><li>Delete protection, off by default </li></ul><ul><li>Translation id: <orig_id>-lang_code </li></ul>
  36. 36. Multilingual support for your content types <ul><li>try: </li></ul><ul><li>from Products.LinguaPlone.public import * </li></ul><ul><li>except ImportError: </li></ul><ul><li># No multilingual support </li></ul><ul><li>from Products.Archetypes.public import * </li></ul>
  37. 37. Questions/Answers
  38. 38. The End

×