如何从Sphinx或gettext中的po文件中翻译完整文章 [英] How to make translations of full articles from po files in Sphinx or gettext

查看:114
本文介绍了如何从Sphinx或gettext中的po文件中翻译完整文章的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Sphinx编写项目文档.我想翻译我的.rst文件,然后生成并翻译了.po文件. Sphinx可以很好地生成html翻译,但是我想拥有.rst或降价全文(以在其他站点上使用).

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

如何使用这些.po(或.mo)文件的翻译重新创建.rst或降价文件?

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

Sphinx,gettext或Python解决方案将适用. 我试图找到有关此信息,但大多数答案都涉及字符串的翻译,而不是完整文章的翻译.

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.

推荐答案

我终于在sphinx-users官方邮件列表上问了这个问题.那个真的很活跃而且很好. Documatt的Matt(用我的小笔写)给出了以下答案:

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

没有直接方法.此类工具也位于Docutil的待办事项列表上.可能有用的想法:

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

  1. 将您的Sphinx构建为Docutils XML.例如,如果您具有法语本地化(fr),则

  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"

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

在您的项目根目录中.

使用Docutils的工具 xml2rst .

Use Docutils's tool xml2rst.

xml2rst的作者还提供了 svn sourceforge.net 链接到代码.

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

确实有效.但是,多余的空格存在问题.它们在XML的创建过程中出现,并且威胁到格式正确的rst(xml2rst不会删除它们).我要手动删除它们(这不是一个大问题,任何体面的编辑器或sed都可以做到).

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

这篇关于如何从Sphinx或gettext中的po文件中翻译完整文章的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆