z2o-k7e / z2o-k7e.github.io

https://learn.z2o-k7e.world/
61 stars 27 forks source link

How to translate use mdbook-i18-helper to update .po file ? #20

Open Demian101 opened 8 months ago

Demian101 commented 8 months ago

related issue: https://github.com/r12f/potr/issues/7


感谢,我发现 openai 目前的接口限制好像是 3QPM (3 Queries per minute)

一章一章的来确实会好很多,步骤大概就是 :

  1. 首先确保你前一版本的 message.po 已经被翻译好的 en.po 更新(? 这句话的表述是不是有问题)

    不知道为啥运行 msgmerge 命令,message.pot 从来没更新过... 不是很理解这条命令的意义

    $ msgmerge --update po/en.po po/messages.pot
    $ MDBOOK_BOOK__LANGUAGE=en mdbook serve -d book/en
  2. 新建一个 temp mdbook 文件夹

  3. 要翻译的章节summary.md 单独放到 ./src

  4. 使用 mdbook-i18n-helpers 的命令 update message.pot

# 根据 src/* 文件生成 `message.pot`
MDBOOK_OUTPUT='{"xgettext": {"pot-file": "messages.pot"}}' \
  mdbook build -d po

# 根据 `message.pot` 更新 `en.po`
msgmerge --update po/en.po po/messages.pot
  1. 使用 potr 进行翻译,可以使用 potr 提供的 filter 命令过滤缩小翻译范围
potr -p po/en1.po -e openai -t en -k  sk-wrv....fcs  --code
  1. 手动逐个检查 en.po 更新的 #, fuzzy 条目来 review 翻译质量 [un support]
Demian101 commented 8 months ago

一些翻译错误的实例:

每次重新翻译文件需要查看是否 fix:

/Users/soda/Web3/potr/target/debug/potr -p po/enDebug.po -e openai -t en -k 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

确认 bug 都 fix 之后,正式执行翻译:

/Users/soda/Web3/potr/target/debug/potr -p po/en.po -e openai -t en -k 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

: src/SUMMARY.md:5

msgid "1" msgstr "" "Sure, here's the text:\n" "\n" "1."

: src/plonk-arithmetization.md:49

msgid "" "$$ \\begin{array}{|c|c|c|c|c|} \\hline 1 & x_1 & x_2 & x_3 & out \\ " "\\hline 0 & 0 & 0 & 2 & 0 \\ \\hline \\end{array} $$" msgstr "" "$$\n" "\begin{array}{|c|c|c|c|c|}\n" "\hline\n" "1 & x_1 & x_2 & x_3 & out \\\n" "\hline\n" "0 & 0 & 0 & 2 & 0 \\\n" "\hline\n" "\end{array}\n" "$$"

: src/plonk-arithmetization.md:27

msgid "" msgstr "" "I understand. Here is the translation:\n" "\n" ""

skip_translation --st or --skip-translation: Skip translation, only generate po file. Default is false This is useful when we only want to update the PO file with the current message to see format changes, etc.

process_translated: Process translated message. By default, translated messages are skipped. --pt or --process-translated: Process translated messages skip_translated: true

所以默认情况下 pt,st skip_code_blocks, 都不需要额外设置。

skip_text: Skip normal text messages (non-code-blocks) skip_text 看起来会急速略过所有字符...

------------------- test - no - translate - file -------------------

msgid "" msgstr "" "Project-Id-Version: SONiC入门指南\n" "POT-Creation-Date: 2023-10-22T14:54:54+08:00\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: en\n" "Plural-Forms: nplurals=1; plural=0;\n"

: src/plonk-arithmetization.md:31

msgid "R1CS 是通过图中的乘法门为中心,用三个「选择子」矩阵来「选择」乘法门的「左输入」、「右输入」、「输出」都分别连接了那些变量。" msgstr ""

: src/SUMMARY.md:5

msgid "1" msgstr ""

: src/plonk-arithmetization.md:49

msgid "" "$$ \\begin{array}{|c|c|c|c|c|} \\hline 1 & x_1 & x_2 & x_3 & out \\ " "\\hline 0 & 0 & 0 & 2 & 0 \\ \\hline \\end{array} $$" msgstr ""

: src/plonk-arithmetization.md:27

msgid "" msgstr ""