本文整理汇总了Python中PyQt5.QtCore.QTextCodec.setCodecForTr方法的典型用法代码示例。如果您正苦于以下问题:Python QTextCodec.setCodecForTr方法的具体用法?Python QTextCodec.setCodecForTr怎么用?Python QTextCodec.setCodecForTr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QTextCodec
的用法示例。
在下文中一共展示了QTextCodec.setCodecForTr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadTranslators
# 需要导入模块: from PyQt5.QtCore import QTextCodec [as 别名]
# 或者: from PyQt5.QtCore.QTextCodec import setCodecForTr [as 别名]
def loadTranslators(qtTransDir, app, translationFiles=()):
"""
Module function to load all required translations.
@param qtTransDir directory of the Qt translations files (string)
@param app reference to the application object (QApplication)
@param translationFiles tuple of additional translations to
be loaded (tuple of strings)
@return the requested locale (string)
"""
import Preferences
global loaded_translators
if qVersion() < "5.0.0":
# set the default encoding for tr()
QTextCodec.setCodecForTr(QTextCodec.codecForName("utf-8"))
translations = ("qt", "eric6") + translationFiles
loc = Preferences.getUILanguage()
if loc is None:
return
if loc == "System":
loc = QLocale.system().name()
if loc != "C":
dirs = [getConfig('ericTranslationsDir'), Globals.getConfigDir()]
if qtTransDir is not None:
dirs.append(qtTransDir)
loca = loc
for tf in ["{0}_{1}".format(tr, loc) for tr in translations]:
translator, ok = loadTranslatorForLocale(dirs, tf)
loaded_translators[tf] = translator
if ok:
app.installTranslator(translator)
else:
if tf.startswith("eric6"):
loca = None
loc = loca
else:
loc = None
return loc