SemanticScuttle/doc/developers/translation.rst

48 lines
1.3 KiB
ReStructuredText
Raw Permalink Normal View History

2011-05-26 21:21:37 +02:00
===========================
Translating SemanticScuttle
===========================
SemanticScuttle uses gnu gettext for translation. It does not
rely on the php extension but ships with a pure php implementation,
2011-05-26 21:21:37 +02:00
php-gettext_.
Using gettext from within the code is really easy:
2011-05-26 21:21:37 +02:00
Enclose the string you want to translate in a "``T_``" function call.
For example, to translate::
echo "Vote for";
2011-05-26 21:22:43 +02:00
just write ::
2011-05-26 21:21:37 +02:00
echo T_("Vote for");
.. _php-gettext: https://launchpad.net/php-gettext/
Translation basics
2011-05-26 21:21:37 +02:00
==================
2011-05-26 21:22:43 +02:00
We keep one base translation file, ``data/locales/messages.po``.
This file is auto-generated via ``xgettext`` from all our php source files.
In case you added a new string to the code that needs translation,
2011-05-26 21:21:37 +02:00
update the base translation file by running ::
$ php scripts/update-translation-base.php
2011-05-26 21:21:37 +02:00
After that has been done, the changes to the base ``messages.po`` file
need to be merged into the single language translation files,
2011-05-26 21:21:37 +02:00
for example ``data/locales/de_DE/LC_MESSAGES/messages.po``.
2011-05-26 21:21:37 +02:00
Updating them from the master file is as easy as running::
2011-05-26 21:21:37 +02:00
$ php scripts/update-translation.php de_DE
When the translation is ready, the ``.po`` file needs to be compiled
in a machine-readable ``.mo`` file. Use ::
2011-05-26 21:21:37 +02:00
$ php scripts/compile-translation.php de_DE
to achieve that.