Edgewall Software

Changes between Version 31 and Version 32 of TracL10N


Ignore:
Timestamp:
Mar 23, 2007, 12:15:41 PM (17 years ago)
Author:
senger@…
Comment:

i18n in zope

Legend:

Unmodified
Added
Removed
Modified
  • TracL10N

    v31 v32  
    4343The Drupal CMS [http://www.drupal.org] has a nice translation unit for its backend. It uses .po-files that can be edit and translated with the poedit [http://www.poedit.org/] software.
    4444
     45=== Zope ===
     46Zope also uses gettext-catalogs for translation. All basic functionality is provided by the packages  [http://svn.zope.org/Zope3/trunk/src/zope/i18n/ zope.i18n] (language-negotiation, formats for time, date, translation of msgids with languagefallback) and [http://svn.zope.org/Zope3/trunk/src/zope/i18nmessageid/ zope.i18nmessageid]. It also has [http://svn.zope.org/Zope3/trunk/src/zope/i18n/locales/ code to use LDML-files] (Locale Data Markup Language).
     47
     48The template-language provides some special attibutes (e.g. i18n:domain, i18n:translate).
     49Translation in python-code works like this (from [http://svn.zope.org/Zope3/trunk/src/zope/i18nmessageid/messages.txt?rev=65911&view=log])
     50
     51{{{
     52In this example, we create a message factory and assign it to _.  By
     53convention, we use _ as the name of our factory to be compatible with
     54translatable string extraction tools such as xgettext.  We then call _
     55with a string that needs to be translatable:
     56
     57  >>> from zope.i18nmessageid import MessageFactory, Message
     58  >>> _ = MessageFactory("futurama")
     59  >>> robot = _(u"robot-message", u"${name} is a robot.")
     60}}}
     61
     62robot looks like a unicode-string and will be translated depending on the negotiated language and the available message-catalogs.
     63
    4564=== Your Own Example ===
    4665