gpt4 book ai didi

internationalization - 使用 PyQt4 进行国际化的最佳实践

转载 作者:行者123 更新时间:2023-12-04 08:21:31 29 4
gpt4 key购买 nike

我想为我的应用程序添加多语言支持,该应用程序是使用 PyQt4 用 Python 编写的。我一直在寻找有关如何添加多种语言的信息,并希望了解其他人是如何做到这一点的。

Here我读:

The PyQt behaviour is unsatisfactory and may be changed in the future. It is recommended that QCoreApplication.translate() be used in preference to tr() (and trUtf8()). This is guaranteed to work with current and future versions of PyQt and makes it much easier to share message files between Python and C++ code.



pyuic4 生成的文件中我看到类似的东西:
WPopupCalendar.setWindowTitle(QtGui.QApplication.translate("WPopupCalendar", "Календарь", None, QtGui.QApplication.UnicodeUTF8))

这对我来说看起来太长了。我想自己做 tr帮助函数以某种方式将过程自动化。

此外,我找不到描述使用 pyqt4 在 python 中开发多语言应用程序的工作流程和细节的文章。

请你给我一些好的和方便的技术建议吗?

最佳答案

只需使用 tr (或 trUtf8 )无处不在。只打扰 translate当您识别受多重继承问题影响的代码时(这很容易永远不会)。

我建议你看看 Qt 的 i18n overview ,以及 Qt Linguist Manual .它们显然都面向 C++ 项目,但它应该让您非常清楚地了解需要什么。

对于工作示例,您还可以下载 Eric Python IDE 的源代码。 - 它是用 PyQt4 编写的,支持六种或更多语言。

关于internationalization - 使用 PyQt4 进行国际化的最佳实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8115005/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com