添加语言

准备

如果您要翻译的语言尚未由其他人启动,并且您希望为所需语言创建一组新文档,例如 "fr"(法语),那幺您必须首先使用您创建的环境,如 入门 中的指导,特别是 安装依赖关系编译手册

该基础环境将用于:

  • 从英语源文本创建一组新的翻译语言。

  • 执行 make 命令将po文件中的已翻译文本转换为html文件,以便在本地进行测试。

  • 同步其他贡献者添加的英文文本更改。

下面的例子展示了在Linux平台上为法语(语言代码 fr)创建一组新文件的过程。其他平台大同小异。

  1. Create a Blender ID <https://id.blender.org/register/> if you have not done so already

  2. Log into projects.blender.org and Create an Issue requesting for commit access in order to transfer changes to the central repository of the translation team.

  3. 打开一个控制台应用程序实例。

  4. Change the current working directory to the directory of blender-manual, where the instance of Makefile resides.

尝试以英语创建 HTML 文件的编译过程

  1. 如果存在之前的 build 目录,请确保已删除:

    make clean
    
  2. 将所有 rst 文件转换为 pot 翻译文件:

    make gettext
    
  3. 创建 html 文件:

    make html
    
  4. 此后,就可以通过打开 blender-manual/build/html/index.html 文件在本地查看按提示指令创建的 html 文件。

在 HTML 菜单中创建语言条目

  1. Create an entry for the language in the html menu by opening file ./resources/theme/js/version_switch.js (assuming you are at the blender-manual subdirectory).

  2. 查找 var all_langs = {..}; 中的语言表。

  3. 输入条目:"fr": "Fran&ccedil;ais",, ("fr": "Français")。(注意Unicode字符。)

  4. Commit the updated file:

    git add ./resources/theme/js/version_switch.js
    git commit -m "HTML: Add French to language menu"
    
  5. Push your changes to the upstream repository:

    git push
    

生成目标语言的文件集

  1. 使用以下命令检验当前的翻译库:

    git clone https://projects.blender.org/blender/blender-manual-translations.git locale
    

    This will download all language sets available in the repository into the locale directory of your drive. You can go to the locale directory to see the hidden subdirectory .git within it, together with directories of languages. You'll need to add your own set of files for the language you are trying to translating to.

  2. blender-manual 目录生成一组用于 fr 语言的文件:

    make update_po
    

    这些文件仍然仅以英文显示,所有 msgstr 条目均为空白。

  3. 将新一组文件提交到中央存储库:

    cd locale
    git add fr
    git commit -m "Initial commit language set of files for French"
    

Tip

  • 建议你在 .bashrc 中为这些目录创建两个环境变量,以方便修改或编写用于翻译和查看结果的批处理/shell命令:

    export BLENDER_MAN_EN=$HOME/<directory to make file directory above>/blender-manual
    export BLENDER_MAN_FR=$BLENDER_MAN_EN/locale
    
  • Newly generated files will contain some placeholders for authors and revision dates etc. If you find the job of replacing them repetitive, make use of the script change_placeholders.sh in the subdirectory ~/blender-manual/tools_maintenance, make a copy of that to your local bin directory and replace all values that were mentioned in the file with your specific details, then after each change to a file, you would do following commands to update the file with your personal details, revision date and time, plus generating the html files for your language, which you can view using your Internet browser:

    $HOME/bin/change_placeholders.sh $BLENDER_MAN_FR
    make -d --trace -w -B -e SPHINXOPTS="-D language='fr'" 2>&1