Yaroslav Nikitenko
Yaroslav Nikitenko

Reputation: 1853

How to make translations of full articles from po files in Sphinx or gettext

I'm writing a project documentation in Sphinx. I want to make translations of my .rst files, and I generated and translated .po files. Sphinx generates html translations fine, but I want to have .rst or markdown full articles (to use them on another site).

How can I recreate .rst or markdown files with translations from these .po (or .mo) files?

Sphinx, gettext or Python solutions will suit. I tried to find information about that, but most answers concern translation of a string, not of a complete article.

Upvotes: 2

Views: 773

Answers (1)

Yaroslav Nikitenko
Yaroslav Nikitenko

Reputation: 1853

I finally asked this question on the sphinx-users official mailing list. That one is really active and good. Matt from Documatt gave the following answer (with my small rewriting):

There is no direct way. Such a tool is on Docutil's todo list too. Just the idea that might help:

  1. Build your Sphinx to Docutils XML. For example, if you have French localization (fr), then

    sphinx-build -b xml source_dir output_dir -D language="fr"

    in your project root.

  2. Use Docutils's tool xml2rst.

The author of xml2rst also gave svn and sourceforge.net links to the code.

That worked indeed. There was a problem with extra whitespaces, however. They appeared during creation of the XML, and they threaten a well-formed rst (the xml2rst doesn't erase them). I'm going to delete them manually (this is not a big problem, any decent editor or sed can do that).

Upvotes: 1

Related Questions