如何使用 PySide6 为 Qt Linguist 创建 .ts 文件?

How to create .ts files for Qt Linguist with PySide6?

我有一个用 PySide2 编写的 python 项目,现在我想迁移到 PySide6。我使用 Qt Linguist 翻译 UI 并借助此命令创建了 .ts 文件: pylupdate5 来自 PyQt5 包的实用程序(但它适用于我使用 PySide2 的项目)。现在我打算去掉 PySide2 和 PyQt5 包。

所以,我需要用 PySide6 包中的东西替换 pylupdate5。我认为 lupdate 应该可以胜任这项工作,但它似乎只适用于 C++ 代码。它给了我 Unterminated C++ characterUnbalanced opening parenthesis in C++ code 之类的错误。 lupdate -help 我不知道如何将它切换到 python 模式(类似于 uic -g python)。

有谁知道如何从 python 个源文件为 Qt Linguist 创建 .ts 个文件?

Qt 6.1 的 lupdate 不支持 Python 但在 Qt 6.2 中该问题不再存在,因此您有 2 个选择:

  • 安装 Qt 6.2 并使用其 lupdate。
  • 等待PySide6 6.2.0发布(目前只支持windows),使用lupdate。