本文整理汇总了Python中Tools.ISO639.LanguageCodes.iteritems方法的典型用法代码示例。如果您正苦于以下问题:Python LanguageCodes.iteritems方法的具体用法?Python LanguageCodes.iteritems怎么用?Python LanguageCodes.iteritems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tools.ISO639.LanguageCodes
的用法示例。
在下文中一共展示了LanguageCodes.iteritems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Tools.ISO639 import LanguageCodes [as 别名]
# 或者: from Tools.ISO639.LanguageCodes import iteritems [as 别名]
def __init__(self):
from Components.Language import language as syslanguage
syslang = syslanguage.getLanguage()[:2]
self.langdict = { }
self.choices = []
for key, val in LanguageCodes.iteritems():
if len(key) == 2:
self.langdict[key] = val[0]
for key, val in self.langdict.iteritems():
if key not in (syslang, 'en'):
self.langdict[key] = val
self.choices.append((key, val))
self.choices.sort()
self.choices.insert(0,("nolang", ("unspecified")))
self.choices.insert(1,(syslang, self.langdict[syslang]))
self.choices.insert(2,("en", self.langdict["en"]))
示例2: getLanguage
# 需要导入模块: from Tools.ISO639 import LanguageCodes [as 别名]
# 或者: from Tools.ISO639.LanguageCodes import iteritems [as 别名]
def getLanguage(self, DVB_lang):
DVB_lang = DVB_lang.lower()
for word in ("stereo", "audio", "description", "2ch", "dolby digital"):
DVB_lang = DVB_lang.replace(word,"").strip()
for key, val in LanguageCodes.iteritems():
if DVB_lang.find(key.lower()) == 0:
if len(key) == 2:
return key
else:
DVB_lang = (LanguageCodes[key])[0]
elif DVB_lang.find(val[0].lower()) > -1:
if len(key) == 2:
return key
else:
DVB_lang = (LanguageCodes[key])[0]
for key, val in self.langdict.iteritems():
if val == DVB_lang:
return key
return "nolang"