| 45 | === Zope === |
| 46 | Zope 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 | |
| 48 | The template-language provides some special attibutes (e.g. i18n:domain, i18n:translate). |
| 49 | Translation in python-code works like this (from [http://svn.zope.org/Zope3/trunk/src/zope/i18nmessageid/messages.txt?rev=65911&view=log]) |
| 50 | |
| 51 | {{{ |
| 52 | In this example, we create a message factory and assign it to _. By |
| 53 | convention, we use _ as the name of our factory to be compatible with |
| 54 | translatable string extraction tools such as xgettext. We then call _ |
| 55 | with 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 | |
| 62 | robot looks like a unicode-string and will be translated depending on the negotiated language and the available message-catalogs. |
| 63 | |