Sphinx を使用したドキュメントの翻訳

Sphinx は美しいドキュメントを作成するためのツールです。単純な reStructuredText 構文を使用し、多くのファイル形式で出力を生成できます。使用例を探さなくても、このドキュメントも Sphinx を使用して作成しています。Sphinx の使用に最適なサービスは Read the Docs サービスです。このサービスは、ドキュメントを無料で作成および公開できます。

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 a few configuration directives and invoking the sphinx-intl tool.

If you are using Read the Docs service, you can start building translated documentation on Read the Docs. Their Localization and Internationalization covers pretty much everything you need - creating another project, setting its language, and linking it from the 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, which 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 コンポーネントの検出 add-on to automatically discover all others.

コンポーネント構成

コンポーネント名

Documentation

ファイル マスク

docs/locales/*/LC_MESSAGES/index.po

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

docs/locales/index.pot

ファイル形式

gettext 用の PO ファイル

翻訳フラグ

rst-text

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

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

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

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

Documentation: {{ component|title }}

新しい翻訳用の、基礎となる翻訳ファイルの設定

docs/locales/{{ component }}.pot

ヒント

Sphinx で PO ファイルを 1 つだけ生成するには? Sphinx 3.3.0 以降で有効な生成方法:

gettext_compact = "docs"

この方法を使用して翻訳されたプロジェクトのドキュメント: