我如何修复 Weblate 无法提交更改的问题
问题
在我的 Weblate 实例中,有一个项目显示了超过 1700 个待处理更改,点击 Commit 没有任何反应(甚至连错误消息都没有)。
Weblate 日志中包含类似以下的消息:
weblate_logs.txt
weblate-1 | [2025-11-16 23:16:08,059: WARNING/489] Could not parse template file on commit: FileParseError: Opening and ending tag mismatch: body line 4 and trans-unit, line 1540, column 20 (<string>, line 1540)
weblate-1 | [2025-11-16 23:16:08,060: ERROR/489] myproject/ui: skipping commit due to error: Opening and ending tag mismatch: body line 4 and trans-unit, line 1540, column 20 (<string>, line 1540)解决方案
如果 Weblate 无法提交,通常由以下两种原因之一引起:
- (1)git 树以某种方式损坏(例如需要强制推送)。这通常很容易修复,只需在设置中将
Version control system设置为Git with force push(如有需要,还要允许 Weblate 的 git 用户进行强制推送)。 - (2)某个 XLIFF 文件中存在语法错误。可以通过将所有 XLIFF 文件(源文件和所有语言的翻译文件)上传到 XLIFF 验证器(如 https://dev.maxprograms.com/Validation/)来检查。
在我的情况中,问题出在(2):其中一个翻译的 XLIFF 文件包含语法错误——不是错误消息所提示的缺少闭合标签,而是一个没有正确转义为 & 的 & 字符。在源文件中修复此问题、提交、推送并在 Weblate 的仓库维护中执行 Updating 后,Weblate 就能够正常提交和推送更改了。
Check out similar posts by category:
Internationalization
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow