本文整理匯總了Python中xbmc.getLanguage方法的典型用法代碼示例。如果您正苦於以下問題:Python xbmc.getLanguage方法的具體用法?Python xbmc.getLanguage怎麽用?Python xbmc.getLanguage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xbmc
的用法示例。
在下文中一共展示了xbmc.getLanguage方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_language
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import getLanguage [as 別名]
def get_language(self):
"""
The xbmc.getLanguage() method is fucked up!!! We always return 'en-US' for now
"""
return 'en-US'
"""
if self.get_system_version().get_release_name() == 'Frodo':
return 'en-US'
try:
language = xbmc.getLanguage(0, region=True)
language = language.split('-')
language = '%s-%s' % (language[0].lower(), language[1].upper())
return language
except Exception, ex:
self.log_error('Failed to get system language (%s)', ex.__str__())
return 'en-US'
pass
"""
示例2: show_about
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import getLanguage [as 別名]
def show_about():
if kodi.get_setting('disable_about') == 'true': return
interval = int(kodi.get_setting('last_about'))
if interval == 0:
interval = 5
try:
import xbmc
KODI_LANGUAGE = xbmc.getLanguage()
except:
KODI_LANGUAGE = 'English'
path = kodi.vfs.join(kodi.get_path(), 'resources/language/%s/github_help.txt', KODI_LANGUAGE)
if not kodi.vfs.exists(path):
path = kodi.vfs.join(kodi.get_path(), 'resources/language/English/github_help.txt')
text = kodi.vfs.read_file(path)
kodi.dialog_textbox('GitHub Browser Instructions', text)
else:
interval -= 1
kodi.set_setting('last_about', interval)
示例3: get_xbmc_language
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import getLanguage [as 別名]
def get_xbmc_language():
import xbmc
langs = {
"english": "en",
"french": "fr",
}
return langs.get(xbmc.getLanguage().lower())
示例4: make_visitor
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import getLanguage [as 別名]
def make_visitor():
from pyga.requests import Visitor
visitor = Visitor()
visitor.user_agent = get_user_agent()
visitor.locale = xbmc.getLanguage()
return visitor
示例5: get_kodi_audio_language
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import getLanguage [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
示例6: convert_language_iso
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import getLanguage [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'
示例7: apiLanguage
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import getLanguage [as 別名]
def apiLanguage(ret_name=None):
langDict = {'Bulgarian': 'bg', 'Chinese': 'zh', 'Croatian': 'hr', 'Czech': 'cs', 'Danish': 'da', 'Dutch': 'nl', 'English': 'en', 'Finnish': 'fi', 'French': 'fr', 'German': 'de', 'Greek': 'el', 'Hebrew': 'he', 'Hungarian': 'hu', 'Italian': 'it', 'Japanese': 'ja', 'Korean': 'ko', 'Norwegian': 'no', 'Polish': 'pl', 'Portuguese': 'pt', 'Romanian': 'ro', 'Russian': 'ru', 'Serbian': 'sr', 'Slovak': 'sk', 'Slovenian': 'sl', 'Spanish': 'es', 'Swedish': 'sv', 'Thai': 'th', 'Turkish': 'tr', 'Ukrainian': 'uk'}
trakt = ['bg','cs','da','de','el','en','es','fi','fr','he','hr','hu','it','ja','ko','nl','no','pl','pt','ro','ru','sk','sl','sr','sv','th','tr','uk','zh']
tvdb = ['en','sv','no','da','fi','nl','de','it','es','fr','pl','hu','el','tr','ru','he','ja','pt','zh','cs','sl','hr','ko']
youtube = ['gv', 'gu', 'gd', 'ga', 'gn', 'gl', 'ty', 'tw', 'tt', 'tr', 'ts', 'tn', 'to', 'tl', 'tk', 'th', 'ti', 'tg', 'te', 'ta', 'de', 'da', 'dz', 'dv', 'qu', 'zh', 'za', 'zu', 'wa', 'wo', 'jv', 'ja', 'ch', 'co', 'ca', 'ce', 'cy', 'cs', 'cr', 'cv', 'cu', 'ps', 'pt', 'pa', 'pi', 'pl', 'mg', 'ml', 'mn', 'mi', 'mh', 'mk', 'mt', 'ms', 'mr', 'my', 've', 'vi', 'is', 'iu', 'it', 'vo', 'ii', 'ik', 'io', 'ia', 'ie', 'id', 'ig', 'fr', 'fy', 'fa', 'ff', 'fi', 'fj', 'fo', 'ss', 'sr', 'sq', 'sw', 'sv', 'su', 'st', 'sk', 'si', 'so', 'sn', 'sm', 'sl', 'sc', 'sa', 'sg', 'se', 'sd', 'lg', 'lb', 'la', 'ln', 'lo', 'li', 'lv', 'lt', 'lu', 'yi', 'yo', 'el', 'eo', 'en', 'ee', 'eu', 'et', 'es', 'ru', 'rw', 'rm', 'rn', 'ro', 'be', 'bg', 'ba', 'bm', 'bn', 'bo', 'bh', 'bi', 'br', 'bs', 'om', 'oj', 'oc', 'os', 'or', 'xh', 'hz', 'hy', 'hr', 'ht', 'hu', 'hi', 'ho', 'ha', 'he', 'uz', 'ur', 'uk', 'ug', 'aa', 'ab', 'ae', 'af', 'ak', 'am', 'an', 'as', 'ar', 'av', 'ay', 'az', 'nl', 'nn', 'no', 'na', 'nb', 'nd', 'ne', 'ng', 'ny', 'nr', 'nv', 'ka', 'kg', 'kk', 'kj', 'ki', 'ko', 'kn', 'km', 'kl', 'ks', 'kr', 'kw', 'kv', 'ku', 'ky']
name = None
name = setting('api.language')
if not name: name = 'AUTO'
if name[-1].isupper():
try: name = xbmc.getLanguage(xbmc.ENGLISH_NAME).split(' ')[0]
except: pass
try: name = langDict[name]
except: name = 'en'
lang = {'trakt': name} if name in trakt else {'trakt': 'en'}
lang['tvdb'] = name if name in tvdb else 'en'
lang['youtube'] = name if name in youtube else 'en'
if ret_name:
lang['trakt'] = [i[0] for i in langDict.iteritems() if i[1] == lang['trakt']][0]
lang['tvdb'] = [i[0] for i in langDict.iteritems() if i[1] == lang['tvdb']][0]
lang['youtube'] = [i[0] for i in langDict.iteritems() if i[1] == lang['youtube']][0]
return lang
示例8: get_language
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import getLanguage [as 別名]
def get_language(language_format=xbmc.ENGLISH_NAME, region=False):
language = xbmc.getLanguage(language_format, region)
if not language or region and language.startswith('-'):
engname = xbmc.getLanguage(xbmc.ENGLISH_NAME)
regiontag = language
if ' (' in engname:
language = engname[:engname.rfind(' (')]
if language_format != xbmc.ENGLISH_NAME:
language = xbmc.convertLanguage(language, language_format) + regiontag
return language
示例9: GetLanguage
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import getLanguage [as 別名]
def GetLanguage(self, *args, **kwargs):
return xbmc.getLanguage(*args, **kwargs)
示例10: get_language
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import getLanguage [as 別名]
def get_language():
try:
language = xbmc.getLanguage(xbmc.ISO_639_1, True)
languageParts = language.split("-")
return "{}_{}.UTF-8".format(languageParts[0], languageParts[1])
except:
return ""
示例11: get_language_code
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import getLanguage [as 別名]
def get_language_code():
import xbmc
return xbmc.getLanguage(format=xbmc.ISO_639_1, region=True)
示例12: about
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import getLanguage [as 別名]
def about():
try:
import xbmc
KODI_LANGUAGE = xbmc.getLanguage()
except:
KODI_LANGUAGE = 'English'
path = kodi.vfs.join(kodi.get_path(), 'resources/language/%s/github_help.txt', KODI_LANGUAGE)
if not kodi.vfs.exists(path):
path = kodi.vfs.join(kodi.get_path(), 'resources/language/English/github_help.txt')
text = kodi.vfs.read_file(path)
kodi.dialog_textbox('GitHub Browser Instructions', text)
示例13: apiLanguage
# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import getLanguage [as 別名]
def apiLanguage(ret_name=None):
langDict = {'Bulgarian': 'bg', 'Chinese': 'zh', 'Croatian': 'hr', 'Czech': 'cs', 'Danish': 'da', 'Dutch': 'nl',
'English': 'en', 'Finnish': 'fi', 'French': 'fr', 'German': 'de', 'Greek': 'el', 'Hebrew': 'he',
'Hungarian': 'hu', 'Italian': 'it', 'Japanese': 'ja', 'Korean': 'ko', 'Norwegian': 'no', 'Polish': 'pl',
'Portuguese': 'pt', 'Romanian': 'ro', 'Russian': 'ru', 'Serbian': 'sr', 'Slovak': 'sk',
'Slovenian': 'sl', 'Spanish': 'es', 'Swedish': 'sv', 'Thai': 'th', 'Turkish': 'tr', 'Ukrainian': 'uk'}
trakt = ['bg', 'cs', 'da', 'de', 'el', 'en', 'es', 'fi', 'fr', 'he', 'hr', 'hu', 'it', 'ja', 'ko', 'nl', 'no', 'pl',
'pt', 'ro', 'ru', 'sk', 'sl', 'sr', 'sv', 'th', 'tr', 'uk', 'zh']
tvdb = ['en', 'sv', 'no', 'da', 'fi', 'nl', 'de', 'it', 'es', 'fr', 'pl', 'hu', 'el', 'tr', 'ru', 'he', 'ja', 'pt',
'zh', 'cs', 'sl', 'hr', 'ko']
youtube = ['gv', 'gu', 'gd', 'ga', 'gn', 'gl', 'ty', 'tw', 'tt', 'tr', 'ts', 'tn', 'to', 'tl', 'tk', 'th', 'ti',
'tg', 'te', 'ta', 'de', 'da', 'dz', 'dv', 'qu', 'zh', 'za', 'zu', 'wa', 'wo', 'jv', 'ja', 'ch', 'co',
'ca', 'ce', 'cy', 'cs', 'cr', 'cv', 'cu', 'ps', 'pt', 'pa', 'pi', 'pl', 'mg', 'ml', 'mn', 'mi', 'mh',
'mk', 'mt', 'ms', 'mr', 'my', 've', 'vi', 'is', 'iu', 'it', 'vo', 'ii', 'ik', 'io', 'ia', 'ie', 'id',
'ig', 'fr', 'fy', 'fa', 'ff', 'fi', 'fj', 'fo', 'ss', 'sr', 'sq', 'sw', 'sv', 'su', 'st', 'sk', 'si',
'so', 'sn', 'sm', 'sl', 'sc', 'sa', 'sg', 'se', 'sd', 'lg', 'lb', 'la', 'ln', 'lo', 'li', 'lv', 'lt',
'lu', 'yi', 'yo', 'el', 'eo', 'en', 'ee', 'eu', 'et', 'es', 'ru', 'rw', 'rm', 'rn', 'ro', 'be', 'bg',
'ba', 'bm', 'bn', 'bo', 'bh', 'bi', 'br', 'bs', 'om', 'oj', 'oc', 'os', 'or', 'xh', 'hz', 'hy', 'hr',
'ht', 'hu', 'hi', 'ho', 'ha', 'he', 'uz', 'ur', 'uk', 'ug', 'aa', 'ab', 'ae', 'af', 'ak', 'am', 'an',
'as', 'ar', 'av', 'ay', 'az', 'nl', 'nn', 'no', 'na', 'nb', 'nd', 'ne', 'ng', 'ny', 'nr', 'nv', 'ka',
'kg', 'kk', 'kj', 'ki', 'ko', 'kn', 'km', 'kl', 'ks', 'kr', 'kw', 'kv', 'ku', 'ky']
name = setting('api.language')
if name[-1].isupper():
try:
name = xbmc.getLanguage(xbmc.ENGLISH_NAME).split(' ')[0]
except:
pass
try:
name = langDict[name]
except:
name = 'en'
lang = {'trakt': name} if name in trakt else {'trakt': 'en'}
lang['tvdb'] = name if name in tvdb else 'en'
lang['youtube'] = name if name in youtube else 'en'
if ret_name:
lang['trakt'] = [i[0] for i in langDict.iteritems() if i[1] == lang['trakt']][0]
lang['tvdb'] = [i[0] for i in langDict.iteritems() if i[1] == lang['tvdb']][0]
lang['youtube'] = [i[0] for i in langDict.iteritems() if i[1] == lang['youtube']][0]
return lang