本文整理汇总了Python中PyQt5.QtCore.QLocale.system方法的典型用法代码示例。如果您正苦于以下问题:Python QLocale.system方法的具体用法?Python QLocale.system怎么用?Python QLocale.system使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QLocale
的用法示例。
在下文中一共展示了QLocale.system方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UItranslations
# 需要导入模块: from PyQt5.QtCore import QLocale [as 别名]
# 或者: from PyQt5.QtCore.QLocale import system [as 别名]
def UItranslations(self):
""" Get list of available ui translations
"""
# iterate over resource file to find available translations
fltr = QDir.Dirs | QDir.Files | QDir.Hidden
iterator = QDirIterator(':', fltr, QDirIterator.Subdirectories)
while iterator.hasNext():
filePath = iterator.next()
if '/translations/ts/' in filePath:
fileName = os.path.basename(str(filePath[1:]))
locale = fileName.replace('lector_','').replace('.qm', '')
if locale:
self.ui.cbLang.addItem(locale)
locale = settings.get('ui:lang')
if not locale:
locale = QLocale.system().name()
currentIndex = self.ui.cbLang.findText(locale)
if currentIndex <= -1:
currentIndex = self.ui.cbLang.findText('en_GB')
self.ui.cbLang.setCurrentIndex(currentIndex)
示例2: load
# 需要导入模块: from PyQt5.QtCore import QLocale [as 别名]
# 或者: from PyQt5.QtCore.QLocale import system [as 别名]
def load(self, *args, default_path=None):
"""
Loads a Python (or other supported) file from the file system or
extracts a Python script from a hex file.
"""
# Get all supported extensions from the different modes
extensions = ["py"]
for mode_name, mode in self.modes.items():
if mode.file_extensions:
extensions += mode.file_extensions
extensions = set([e.lower() for e in extensions])
extensions = "*.{} *.{}".format(
" *.".join(extensions), " *.".join(extensions).upper()
)
folder = self.get_dialog_directory(default_path)
allow_previous = not bool(default_path)
path = self._view.get_load_path(
folder, extensions, allow_previous=allow_previous
)
if path:
self.current_path = os.path.dirname(os.path.abspath(path))
self._load(path)
示例3: get_default_locale
# 需要导入模块: from PyQt5.QtCore import QLocale [as 别名]
# 或者: from PyQt5.QtCore.QLocale import system [as 别名]
def get_default_locale():
return QLocale.system()
示例4: getDictionaryPath
# 需要导入模块: from PyQt5.QtCore import QLocale [as 别名]
# 或者: from PyQt5.QtCore.QLocale import system [as 别名]
def getDictionaryPath(self):
dicPath = os.path.join(Resources.SPELL_DICT_PATH, QLocale.system().name())
if self.dictionaryExists(dicPath):
return dicPath
return ''
示例5: get_locale_language
# 需要导入模块: from PyQt5.QtCore import QLocale [as 别名]
# 或者: from PyQt5.QtCore.QLocale import system [as 别名]
def get_locale_language():
return QLocale.system().name()[:2].lower()
示例6: getLang
# 需要导入模块: from PyQt5.QtCore import QLocale [as 别名]
# 或者: from PyQt5.QtCore.QLocale import system [as 别名]
def getLang(cls):
"""根据配置文件读取语言配置,如果没有找到当前系统配置
:return:
"""
config = Config.current()
Language.lang = config["general.language"]
if not Language.lang.strip():
# import locale
# lang,country=locale.getdefaultlocale()
Language.lang = QLocale.system().name() # 语言_国家”形式形成的字符串,比如zh_CN。
# QLocale.languageToString(QLocale.system().language()) #语言英文名称,比如English,Chinese
# QLocale.system().nativeLanguageName() #语言自身的写法比如:中文(简体)
return Language.lang
示例7: setTrans
# 需要导入模块: from PyQt5.QtCore import QLocale [as 别名]
# 或者: from PyQt5.QtCore.QLocale import system [as 别名]
def setTrans(cls):
"""根据配置文件(如果没有就根据当前系统语言)设置当前语言包
"""
langs = Language.getLangs()
lang = Language.getLang()
qmfile = None
for l in langs:
if lang in (l["lang"], l["lang"].replace("-", "_")):
qmfile = l["qmfile"]
break
if qmfile is None:
lang = "en"
try:
if lang == "en":
# qApp.removeTranslator(self.qmfile)
# qApp.removeTranslator(self.trans_sys)
pass
else:
transdir = os.path.dirname(__file__)
if os.path.exists(os.path.join(transdir, qmfile)):
Language.trans.load(qmfile, transdir)
QApplication.installTranslator(Language.trans)
except Exception as Argument:
print(Argument)
systransdir = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
try:
if Language.systrans.load("qt_" + QLocale(lang).name(), systransdir):
QApplication.installTranslator(Language.systrans)
if Language.systrans.load("qscintilla_" + QLocale(lang).name(), systransdir):
QApplication.installTranslator(Language.systrans)
except Exception:
Language.systrans.load("qt_" + QLocale.system().name(), systransdir)
QApplication.installTranslator(Language.systrans)
示例8: get_admin_file_path
# 需要导入模块: from PyQt5.QtCore import QLocale [as 别名]
# 或者: from PyQt5.QtCore.QLocale import system [as 别名]
def get_admin_file_path(filename):
"""
Given an admin related filename, this function will attempt to get the
most relevant version of this file (the default location is the application
data directory, although a file of the same name in the same directory as
the application itself takes preference). If this file isn't found, an
empty one is created in the default location.
"""
# App location depends on being interpreted by normal Python or bundled
app_path = sys.executable if getattr(sys, "frozen", False) else sys.argv[0]
app_dir = os.path.dirname(os.path.abspath(app_path))
# The os x bundled application is placed 3 levels deep in the .app folder
if platform.system() == "Darwin" and getattr(sys, "frozen", False):
app_dir = os.path.dirname(os.path.dirname(os.path.dirname(app_dir)))
file_path = os.path.join(app_dir, filename)
if not os.path.exists(file_path):
file_path = os.path.join(DATA_DIR, filename)
if not os.path.exists(file_path):
try:
with open(file_path, "w") as f:
logger.debug("Creating admin file: {}".format(file_path))
json.dump({}, f)
except FileNotFoundError:
logger.error(
"Unable to create admin file: {}".format(file_path)
)
return file_path
示例9: show_help
# 需要导入模块: from PyQt5.QtCore import QLocale [as 别名]
# 或者: from PyQt5.QtCore.QLocale import system [as 别名]
def show_help(self):
"""
Display browser based help about Mu.
"""
language_code = QLocale.system().name()[:2]
major_version = ".".join(__version__.split(".")[:2])
url = "https://codewith.mu/{}/help/{}".format(
language_code, major_version
)
logger.info("Showing help at %r.", url)
webbrowser.open_new(url)