Translating documentation using Sphinx

Sphinx is a tool for creating beautiful documentation. It uses simple reStructuredText syntax and can generate output in many formats. If you're looking for an example, this documentation is also built using it. The very useful companion for using Sphinx is the Read the Docs service, which will build and publish your documentation for free.

I will not focus on writing documentation itself, if you need guidance with that, just follow instructions on the Sphinx website. Once you have documentation ready, translating it is quite easy as Sphinx comes with support for this and it is quite nicely covered in their 国際化. It's matter of few configuration directives and invoking of the sphinx-intl tool.

If you are using Read the Docs service, you can start building translated documentation on the Read the Docs. Their Localization of Documentation covers pretty much everything you need - creating another project, set its language and link it from main project as a translation.

Now all you need is translating the documentation content. Sphinx generates PO file for each directory or top level file, what can lead to quite a lot of files to translate (depending on gettext_compact settings). You can import the index.po into Weblate as an initial component and then configure コンポーネントの検出 addon to automatically discover all others.

Component configuration

コンポーネント名

Documentation

File mask

docs/locales/*/LC_MESSAGES/index.po

新しい翻訳のテンプレート

docs/locales/index.pot

ファイル形式

gettext PO file

翻訳フラグ

rst-text

コンポーネント検出の設定

翻訳ファイルを照合する正規表現

docs/locales/(?P<language>[^/.]*)/LC_MESSAGES/(?P<component>[^/]*)\.po

コンポーネント名のカスタマイズ

Documentation: {{ component|title }}

新しい翻訳に対する基本ファイルの定義

docs/locales/{{ component }}.pot

ヒント

Would you prefer Sphinx to generate just single PO file? Since Sphinx 3.3.0 you can achieve this using:

gettext_compact = "docs"

You can find several documentation projects being translated using this approach: