Jump to: navigation, search

Difference between revisions of "I18n/Tools"

(Remove reference to DocBook)
(Replaced content with "Category:I18n The contents was moved to https://docs.openstack.org/i18n/latest/tools.html")
Line 1: Line 1:
I18N uses many different tools, across several OpenStack Projects to meet its goals.
The contents was moved to https://docs.openstack.org/i18n/latest/tools.html
== Tools related with document translation ==
OpenStack documents are using RST format. The steps to translate RST documents include:
* Slicing: generate PO templates from RST documents
* Uploading: Upload the translation resources to Zanata
* Translating: manage the translation in Zanata, including the translation memory and glossary management
* Downloading: Download the translated results by automation scripts.
* Building: Build HTML from RST documents and the translated results.
Sphinx is a tool to translate RST source files to various output formats, including POT and HTML. You need to install Sphinx before you go to below steps.
pip install Sphinx
All of this is automated from Jenkins jobs.
=== Slicing ===
We use sphinx-build to translate RST files to POT files. Because we want to have a single POT file per document, we use msgcat to merge those POTs after sphinx-build.
sphinx-build -b gettext doc/[docname]/source/ doc/[docname]/source/locale/
msgcat doc/[docname]/source/locale/*.pot > doc/[docname]/source/locale/[docname].pot
=== Uploading ===
We use Zanata client to upload the POT file to the [http://translate.openstack.org Zanata instance].
=== Downloading ===
We use Zanata client to download the translated PO files from  [http://translate.openstack.org Zanata instance].
=== Building ===
Before use sphinx-build to build HTML file, we need to feed the translations from the single PO file into those small PO files.
For example:
msgmerge -o doc/[docname]/source/locale/zh_CN/LC_MESSAGES/A.po doc/[docname]/source/locale/zh_CN/LC_MESSAGES/[docname].po doc/[docname]/source/locale/A.pot
Then, for evey PO file, we should execute the following command to build into MO file:
msgfmt "doc/[docname]/source/locale/zh_CN/LC_MESSAGES/A.po" -o "doc/[docname]/source/locale/zh_CN/LC_MESSAGES/A.mo"
Finally, we could generate HTML files by
sphinx-build -D "language='zh_CN' doc/[docname]/source/ doc/[docname]/build/html
== Tools related with message translation ==
For most of the Python projects, the preferred tools for I18N are gettext and babel. The gettext module provides internationalization (I18N) and localization (L10N) services for your Python modules and applications. Babel are a collection of tools for internationalizing Python applications.
You can extract the messages in code to PO template with pybabel:
pybabel extract -o nova/locale/nova.pot nova/
=== Uploading script ===
For each Python project in OpenStack, there is an automation job to extract the messages , generate PO template and upload to Zanata, which is triggered by the "commit" event. See [https://github.com/openstack-infra/config/blob/master/modules/jenkins/files/slave_scripts/upstream_translation_update.sh here].
=== Downloading script ===
For each Python project in OpenStack, there is an automation job daily to download the translations in po file to the "locale" folder under the source folder of each project. See [https://github.com/openstack-infra/config/blob/master/modules/jenkins/files/slave_scripts/propose_translation_update.sh here]. It will generate a review request in Gerrit. After review, the translation in po file will be merged.

Latest revision as of 14:22, 4 August 2017

The contents was moved to https://docs.openstack.org/i18n/latest/tools.html