本文整理匯總了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)