本文整理汇总了Python中horizons.constants.LANGUAGENAMES.items方法的典型用法代码示例。如果您正苦于以下问题:Python LANGUAGENAMES.items方法的具体用法?Python LANGUAGENAMES.items怎么用?Python LANGUAGENAMES.items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizons.constants.LANGUAGENAMES
的用法示例。
在下文中一共展示了LANGUAGENAMES.items方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_locale
# 需要导入模块: from horizons.constants import LANGUAGENAMES [as 别名]
# 或者: from horizons.constants.LANGUAGENAMES import items [as 别名]
def get_locale(self):
for locale_code, langname in LANGUAGENAMES.items():
if langname == self.get_uh_setting('Language'):
return locale_code
# TODO : better way to find 'System default' ?
default_locale, default_encoding = locale.getdefaultlocale()
return default_locale.split('_')[0]
示例2: get_locale
# 需要导入模块: from horizons.constants import LANGUAGENAMES [as 别名]
# 或者: from horizons.constants.LANGUAGENAMES import items [as 别名]
def get_locale(self):
for locale_code, langname in LANGUAGENAMES.items():
if langname == self.get_uh_setting('Language'):
return locale_code
default_locale, default_encoding = locale.getdefaultlocale()
try:
return default_locale.split('_')[0]
except:
# If default locale could not be detected use 'EN' as fallback
return "en"
示例3: get_locale
# 需要导入模块: from horizons.constants import LANGUAGENAMES [as 别名]
# 或者: from horizons.constants.LANGUAGENAMES import items [as 别名]
def get_locale(self):
for locale_code, langname in LANGUAGENAMES.items():
if langname == self.get_uh_setting('Language'):
if not langname == 'System default':
return locale_code
try:
default_locale, default_encoding = locale.getdefaultlocale()
return default_locale.split('_')[0]
except (ValueError, AttributeError):
# OS X sometimes returns 'UTF-8' as locale, which is a ValueError.
# If no locale is set at all, the split will fail, which is an AttributeError.
# Use 'EN' as fallback in both cases since we cannot reasonably detect the locale.
return "en"