flask-docs-zh icon indicating copy to clipboard operation
flask-docs-zh copied to clipboard

Updated po files contain unexpected changes

Open greyli opened this issue 3 years ago • 10 comments

I tried to update .po files based on the updates from the upstream repo. However, the changes contain a lot of unexpected results:

  • Some Chinese words added into api.po as msgid.
  • The msgid of alt of images was replaced with the translated msgstr.
  • Some multiline msgstr was reordered based on the position of the English word.

We need to fix this issue before running the sync workflow.

See the changes in https://github.com/greyli/flask-docs-zh/pull/35/files.

greyli avatar May 27 '21 03:05 greyli

第一个问题,都是一些api doc中的必备词汇,猜测是sphinx-intl 自动转换免去翻译了(渲染结果验证) 第二个问题我这里没有出现 第三个问题不影响渲染结果

所以总体上是没有大问题,请问你第一次po是如何生成的呢?用的同样的工具不应该结果有异

frostming avatar May 27 '21 06:05 frostming

前两个问题不大,第三个比较麻烦,虽然不影响渲染,但是它会产生很多不必要的变动。如果后续引入 pre-commit 的话会导致冲突(pre-commit 把所有行长度调整好,更新 po 文件后又被打乱) 。

生成工具没变,命令也没变。

我看下有没有方法解决,没办法的话就只能放弃引入 pre-commit 了。

greyli avatar May 27 '21 08:05 greyli

或者在workflow里跑一遍pre-commit

frostming avatar May 27 '21 08:05 frostming

GitHub Actions 里的 git commit 会触发 pre-commit 吗?如果不会那就加一条 pre-commit 命令就好了。

或者在workflow里跑一遍pre-commit

对,发完才看到新评论……

greyli avatar May 27 '21 09:05 greyli

是的,显式运行pre-commit

frostming avatar May 27 '21 09:05 frostming

嗯,不过暂时还不清楚怎么让 pre-commit 检查 po 文件。我先去 https://github.com/sphinx-doc/sphinx-intl 发个 issue 问下输出混乱的问题。

ref: https://github.com/sphinx-doc/sphinx-intl/issues/50

greyli avatar May 27 '21 09:05 greyli

第三个问题,最大行长是默认76的,PR中的行长也没有突破这个值,所以折行稳定性是可以保证的

frostming avatar May 28 '21 07:05 frostming

第三个问题,最大行长是默认76的,PR中的行长也没有突破这个值,所以折行稳定性是可以保证的

设置行长只会控制 msgid 的长度。在那个 PR 里,这一行的长度是 139。我认为更新 po 文件不该变动 msgstr 的值,不过似乎没有提供相应的设置选项。

greyli avatar May 28 '21 08:05 greyli

看明白了,仿佛它不能正确在中文字符内折行,似乎应该报告给Babel

Update: https://github.com/python-babel/babel/issues/787

frostming avatar May 28 '21 09:05 frostming

第三个问题,最大行长是默认76的,PR中的行长也没有突破这个值,所以折行稳定性是可以保证的

我在 Poedit 使用一致的折行设置,但是基本上都会打乱原先的 msgid 折行。每次都要手动更改回去。直接使用文本编辑器编辑,要手动控制折行,打双引号,非常麻烦。不知道有没有好一点的方法。

rosekc avatar May 31 '21 07:05 rosekc