Are there way to generate RST file from translated PO file

48 views
Skip to first unread message

藤田祐治

unread,
Jan 4, 2023, 12:48:30 AM1/4/23
to sphinx...@googlegroups.com
Hi there!

I am using Sphinx for the translated html and pdf by using command

make -e SPHINXOPTS="-D language='ja'" html
make -e SPHINXOPTS="-D language='ja'" latexpdf

from translated PO files.

I am just wondering if there is any good way to generate rst file from translated PO file?
If I can, it will be very helpful and useful.

I saw one to generate an xml file and then xml2rst.
But it looks very complex.

Are there any handy ways to do it?

Thanks
Yuji Fujita

Takayuki Shimizukawa

unread,
Jan 6, 2023, 7:37:23 AM1/6/23
to sphinx...@googlegroups.com
Hi Yuji,

I think there is no easy way to do this.
Sphinx reads the source and converts it to an AST: Abstract Syntax Tree (doctree), where it replaces the messages matching the po file.
The problem is that we cannot reproduce the reST sources from the AST, because most of the structure of the directives is lost upon conversion to the AST.

For this reason, I think a possible practical approach would be to look for a string in the document source that matches the message in the po file and replace it.

Regards,
--
Takayuki SHIMIZUKAWA
http://about.me/shimizukawa


2023年1月4日(水) 14:48 藤田祐治 <yujf...@open-lc.co.jp>:
--
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/CABdx1LvJvU60f5bwAXo-YXUT4a5URmtMM7cJV0M3shLJMrqvvQ%40mail.gmail.com.

藤田祐治

unread,
Jan 6, 2023, 12:24:19 PM1/6/23
to sphinx...@googlegroups.com
Hi Shimazu-san,

Thank you for the email.

That is exactly what I thought as possible solution.

The po file contain the information of the location of the string and source string as msgid and translated string as msgrd.

It looks ok if sorce string is the plain sentence,
But I am not sure I can have one to one mapping of the string  and simply replace if the source comes from table, 

But it will be interesting challenge and will try.

Again thank you very much for the email.

Yuji

2023年1月6日(金) 21:37 Takayuki Shimizukawa <shimi...@gmail.com>:
--
藤田 祐治
オープンリンク株式会社
代表取締役 社長
住所:千葉県千葉市美浜区打瀬2-9-16-414
携帯:080-3694-5550
e-mail: yujf...@open-lc.co.jp

ABHISHEK AGGARWAL

unread,
Jan 8, 2023, 1:23:08 AM1/8/23
to sphinx...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages