当前位置: 首页>>代码示例>>Python>>正文


Python LANGUAGENAMES.items方法代码示例

本文整理汇总了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]
开发者ID:court-jus,项目名称:unknown-horizons,代码行数:9,代码来源:engine.py

示例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"
开发者ID:perher,项目名称:unknown-horizons,代码行数:12,代码来源:engine.py

示例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"
开发者ID:DanielStephens,项目名称:unknown-horizons,代码行数:15,代码来源:engine.py


注:本文中的horizons.constants.LANGUAGENAMES.items方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。