make rst translations of full articles from po files

42 views
Skip to first unread message

Yaroslav Nikitenko

unread,
Apr 27, 2020, 6:17:52β€―AM4/27/20
to sphinx-users
How can I get translated .rst (or markdown) files?

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).


Is it possible to recreate .rst or markdown files with translations from these .po (or .mo) files?

If there is no such option in Sphinx, maybe someone knows how it could be done with gettext or Python?


I posted this question on stackoverflow, but there was no answer yet

(https://stackoverflow.com/questions/61246851/how-to-make-translations-of-full-articles-from-po-files-in-sphinx-or-gettext)


Thank you.


Best regards,

Yaroslav Nikitenko

Matt from Documatt

unread,
Apr 27, 2020, 6:35:39β€―AM4/27/20
to sphinx...@googlegroups.com
Hello Yaroslav,
I think there is no direct way. Such a tool is on Docutil's todo list too (https://docutils.sourceforge.io/docs/user/tools.html#restructuredtext-generating-tools). Just the idea that might help you:
If you succeed, let me know.

--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/fdf34636-ba94-4c18-8c32-ee81623935bc%40googlegroups.com.

Yaroslav Nikitenko

unread,
Apr 28, 2020, 6:23:21β€―AM4/28/20
to sphinx...@googlegroups.com
Hello Matt,

many thanks for your detailed suggestion.

I created xml, but failed to run xml2rst (it prints
... File "/usr/lib/python2.7/site-packages/xml2rstlib/markup.py", line
61, in quoteInline
Β  Β  match = self.patterns.initial.search(remaining)
AttributeError: Inliner instance has no attribute 'patterns')

Then I used pandoc to convert xml to rst. The result was not nice
though, especially with code samples (they were made one-liners).

I sent a question / bug report to the maintainer of xml2rst, but had no answer yet.Β 



2020-04-27 13:35 GMT+03:00, Matt from Documatt <ma...@documatt.com>:
> Hello Yaroslav,
> I think there is no direct way. Such a tool is on Docutil's todo list too (
> https://docutils.sourceforge.io/docs/user/tools.html#restructuredtext-generating-tools).
> Just the idea that might help you:
>
>Β  Β  - Build your Sphinx to Docutils XML (

>
> https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.xml.XMLBuilder).
>Β  Β  For example, if you have French localization (fr), then sphinx-build -b
>Β  Β  xml source_dir output_dir -D language="fr" in your project root.
>Β  Β  - Use Docutils's tool "xml2rst"

>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sphinx-users/CAOGNDW8LiCrnDx8RU6CyThxB3cnb9N3NyQ8J9hzk8P3CRZdvng%40mail.gmail.com.
>


--
Π‘ ΡƒΠ²Π°ΠΆΠ΅Π½ΠΈΠ΅ΠΌ,
Ярослав НикитСнко
+7 916 743 3759

Matt from Documatt

unread,
Apr 28, 2020, 6:55:58β€―AM4/28/20
to sphinx...@googlegroups.com
It looks you are using Python 2. xml2rst is last updated in 2018 and thus maybe will work better in Python 3. But just an idea. It will probablyΒ not help you :-(

Matt

Yaroslav Nikitenko

unread,
Apr 28, 2020, 8:05:06β€―AM4/28/20
to sphinx...@googlegroups.com
Thanks. No, I tried Python 3, but there was a syntax error.Β 


Π²Ρ‚, 28 Π°ΠΏΡ€. 2020 Π³., 13:55 Matt from Documatt <ma...@documatt.com>:

Yaroslav Nikitenko

unread,
Jul 15, 2020, 3:21:00β€―PM7/15/20
to sphinx...@googlegroups.com
Dear Matt and Sphinx users,

this issue was solved in xml2rst. We got in touch with its author and
he made an update (he also noted that his email on his site is not
much used today):
"My tests run and I just pushed V1.3.1 of xml2rst to the sandbox"
svn.code.sf.net/p/docutils/code/trunk/sandbox/xml2rst
or
https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/sandbox/xml2rst/

I should also add that there appear many spurious space indentations
(even in headers).
They appear during creation of the xml file and can be deleted
manually with a good editor or script.

Many thanks for your help!

P.S. I will leave this mailing list in several days, so please include
my email if you want to write to me directly.

Regards,
Yaroslav
>>> <https://groups.google.com/d/msgid/sphinx-users/CA%2BRLzGALTnzqKgb9qazyd53_Z%3DOt%2BR9XH54-%2Bg2dh5W1ZR3RBQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sphinx-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to sphinx-users...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/sphinx-users/CAOGNDW9VKD%2Bk5NPhd6LMoSuYRMHZfsaGNoEODxfZZxcUrGh%2Bow%40mail.gmail.com
>> <https://groups.google.com/d/msgid/sphinx-users/CAOGNDW9VKD%2Bk5NPhd6LMoSuYRMHZfsaGNoEODxfZZxcUrGh%2Bow%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>


--
Π‘ ΡƒΠ²Π°ΠΆΠ΅Π½ΠΈΠ΅ΠΌ,
Ярослав НикитСнко
http://twitter.com/ynikitenko
http://vk.com/yaroslav.nikitenko
http://facebook.com/ynikitenko
+7 916 743 3759

Daniel Scott

unread,
Nov 25, 2020, 10:37:58β€―PM11/25/20
to sphinx...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages