本文整理汇总了Python中xbmc.ISO_639_1属性的典型用法代码示例。如果您正苦于以下问题:Python xbmc.ISO_639_1属性的具体用法?Python xbmc.ISO_639_1怎么用?Python xbmc.ISO_639_1使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类xbmc
的用法示例。
在下文中一共展示了xbmc.ISO_639_1属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_kodi_audio_language
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import ISO_639_1 [as 别名]
def get_kodi_audio_language(iso_format=xbmc.ISO_639_1, use_fallback=True):
"""
Return the audio language from Kodi settings
WARNING: when use_fallback is False, based on Kodi settings can also return values as: 'mediadefault', 'original'
"""
audio_language = json_rpc('Settings.GetSettingValue', {'setting': 'locale.audiolanguage'})
converted_lang = convert_language_iso(audio_language['value'], iso_format, use_fallback)
if not converted_lang:
if audio_language['value'] == 'default':
# Kodi audio language settings is set as "User interface language"
converted_lang = xbmc.getLanguage(iso_format, False) # Get lang. active
else:
converted_lang = audio_language['value']
return converted_lang
示例2: get_kodi_subtitle_language
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import ISO_639_1 [as 别名]
def get_kodi_subtitle_language(iso_format=xbmc.ISO_639_1):
"""
Return the subtitle language from Kodi settings
"""
subtitle_language = json_rpc('Settings.GetSettingValue', {'setting': 'locale.subtitlelanguage'})
if subtitle_language['value'] == 'forced_only':
return subtitle_language['value']
return convert_language_iso(subtitle_language['value'], iso_format)
示例3: convert_language_iso
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import ISO_639_1 [as 别名]
def convert_language_iso(from_value, iso_format=xbmc.ISO_639_1, use_fallback=True):
"""
Convert language code from an English name or three letter code (ISO 639-2) to two letter code (ISO 639-1)
:param iso_format: specify the iso format (ISO_639_1 or ISO_639_2)
:param use_fallback: if True when the conversion fails, is returned the current Kodi active language
"""
converted_lang = xbmc.convertLanguage(g.py2_encode(from_value), iso_format)
if not use_fallback:
return converted_lang
converted_lang = converted_lang if converted_lang else xbmc.getLanguage(iso_format, False) # Get lang. active
return converted_lang if converted_lang else 'en' if iso_format == xbmc.ISO_639_1 else 'eng'
示例4: setlanguages
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import ISO_639_1 [as 别名]
def setlanguages(self):
languages = []
if settings.language_override:
languages.append(settings.language_override)
if settings.language_fallback_kodi:
newlang = pykodi.get_language(xbmc.ISO_639_1)
if newlang not in languages:
languages.append(newlang)
if settings.language_fallback_en and 'en' not in languages:
languages.append('en')
self.autolanguages = languages
log("Working language filter: " + str(languages))
示例5: get_language_code
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import ISO_639_1 [as 别名]
def get_language_code():
import xbmc
return xbmc.getLanguage(format=xbmc.ISO_639_1, region=True)