美文网首页
使用Google Translate 服务批量翻译 Sphinx

使用Google Translate 服务批量翻译 Sphinx

作者: 小杰杰杰 | 来源:发表于2021-01-28 11:21 被阅读0次

    Sphinx

    Sphinx是由Georg Brandl编写并获得BSD许可的,易于创建智能,美观文档的工具。

    安装Sphinx

    pip install -U sphinx
    

    potranslator

    potranslator是一个软件包,可轻松翻译Sphinx或其他工具以Google Translate支持的任何语言生成的po和pot文件。

    安装 potranslator

    pip install potranslator
    

    使用:

    使用Sphinx创建您的文档:
    $ sphinx-build -b html /path/to/docs path/to/docs/_build
    将配置添加到conf.py(如果有)中:
    locale_dirs = ['locale/']   #path is an example but this is the recommended path.
    gettext_compact = False     #optional.
    locale_dirs 是必须的 gettext_compact 是可选的
    将文档的可翻译消息提取到Pot文件中:
    make gettext
    用德语和日语翻译/更新您的文档:
    potranslator update -p _build/gettext -l de -l ja
    完成后 您获得了以下目录,其中包含带有自动翻译条目的po文件:
    ./locale/de/LC_MESSAGES/
    ./locale/ja/LC_MESSAGES/
    用日语翻译/更新您的文档,构建已编译的mo文件并生成已翻译的html文档:
    $ potranslator build
    $ make -e SPHINXOPTS="-D language='ja'" html
    

    就这样!

    注意: potranslator 默认引用的 googletrans是2.3.0版本的,或报错。需要手动安装3.1.0版本

    pip install googletrans==3.1.0a0
    

    相关文章

      网友评论

          本文标题:使用Google Translate 服务批量翻译 Sphinx

          本文链接:https://www.haomeiwen.com/subject/ziettltx.html