本文整理汇总了Python中trans_utils.i18n函数的典型用法代码示例。如果您正苦于以下问题:Python i18n函数的具体用法?Python i18n怎么用?Python i18n使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了i18n函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_disable_check
def do_disable_check():
scrapers = relevant_scrapers()
auto_disable = kodi.get_setting('auto-disable')
check_freq = int(kodi.get_setting('disable-freq'))
disable_thresh = int(kodi.get_setting('disable-thresh'))
for cls in scrapers:
last_check = db_connection.get_setting('%s_check' % (cls.get_name()))
last_check = int(last_check) if last_check else 0
tries = kodi.get_setting('%s_try' % (cls.get_name()))
tries = int(tries) if tries else 0
if tries > 0 and tries / check_freq > last_check / check_freq:
kodi.set_setting('%s_check' % (cls.get_name()), str(tries))
success_rate = calculate_success(cls.get_name())
if success_rate < disable_thresh:
if auto_disable == DISABLE_SETTINGS.ON:
kodi.set_setting('%s-enable' % (cls.get_name()), 'false')
kodi.notify(msg='[COLOR blue]%s[/COLOR] %s' % (i18n('scraper_disabled')), duration=5000)
elif auto_disable == DISABLE_SETTINGS.PROMPT:
dialog = xbmcgui.Dialog()
line1 = i18n('disable_line1') % (cls.get_name(), 100 - success_rate, tries)
line2 = i18n('disable_line2')
line3 = i18n('disable_line3')
ret = dialog.yesno('SALTS', line1, line2, line3, i18n('keep_enabled'), i18n('disable_it'))
if ret:
kodi.set_setting('%s-enable' % (cls.get_name()), 'false')
示例2: get_resume_choice
def get_resume_choice(trakt_id, season, episode):
if kodi.get_setting('trakt_bookmark') == 'true':
resume_point = '%s%%' % (trakt_api.get_bookmark(trakt_id, season, episode))
header = i18n('trakt_bookmark_exists')
else:
resume_point = format_time(db_connection.get_bookmark(trakt_id, season, episode))
header = i18n('local_bookmark_exists')
question = i18n('resume_from') % (resume_point)
return xbmcgui.Dialog().yesno(header, question, '', '', i18n('start_from_beginning'), i18n('resume')) == 1
示例3: get_resume_choice
def get_resume_choice(trakt_id, season, episode):
if kodi.get_setting("trakt_bookmark") == "true":
resume_point = "%s%%" % (trakt_api.get_bookmark(trakt_id, season, episode))
header = i18n("trakt_bookmark_exists")
else:
resume_point = format_time(db_connection.get_bookmark(trakt_id, season, episode))
header = i18n("local_bookmark_exists")
question = i18n("resume_from") % (resume_point)
return xbmcgui.Dialog().yesno(header, question, "", "", i18n("start_from_beginning"), i18n("resume")) == 1
示例4: choose_list
def choose_list(username=None):
lists = trakt_api.get_lists(username)
if username is None: lists.insert(0, {'name': 'watchlist', 'ids': {'slug': WATCHLIST_SLUG}})
if lists:
dialog = xbmcgui.Dialog()
index = dialog.select(i18n('pick_a_list'), [list_data['name'] for list_data in lists])
if index > -1:
return lists[index]['ids']['slug']
else:
kodi.notify(msg=i18n('no_lists_for_user') % (username), duration=5000)
示例5: choose_list
def choose_list(username=None):
lists = trakt_api.get_lists(username)
if username is None:
lists.insert(0, {"name": "watchlist", "ids": {"slug": WATCHLIST_SLUG}})
if lists:
dialog = xbmcgui.Dialog()
index = dialog.select(i18n("pick_a_list"), [list_data["name"] for list_data in lists])
if index > -1:
return lists[index]["ids"]["slug"]
else:
kodi.notify(msg=i18n("no_lists_for_user") % (username), duration=5000)
示例6: onClick
def onClick(self, control):
# print 'onClick: %s' % (control)
if control == AUTH_BUTTON:
if not self.__get_token():
kodi.notify(msg=i18n('pin_auth_failed'), duration=5000)
return
self.auth = True
if control == LATER_BUTTON:
kodi.notify(msg=i18n('remind_in_24hrs'), duration=5000)
kodi.set_setting('last_reminder', str(int(time.time())))
if control == NEVER_BUTTON:
kodi.notify(msg=i18n('use_addon_settings'), duration=5000)
kodi.set_setting('last_reminder', '-1')
if control in [AUTH_BUTTON, LATER_BUTTON, NEVER_BUTTON]:
self.close()
示例7: parallel_get_url
def parallel_get_url(q, scraper, video):
worker = threading.current_thread()
log_utils.log('Worker: %s (%s) for %s url' % (worker.name, worker, scraper.get_name()), log_utils.LOGDEBUG)
url = scraper.get_url(video)
log_utils.log('%s returned url %s from %s' % (scraper.get_name(), url, worker), log_utils.LOGDEBUG)
if not url: url = ''
if url == FORCE_NO_MATCH:
label = '[%s] [COLOR green]%s[/COLOR]' % (scraper.get_name(), i18n('force_no_match'))
else:
label = '[%s] %s' % (scraper.get_name(), url)
related = {'class': scraper, 'url': url, 'name': scraper.get_name(), 'label': label}
q.put(related)
示例8: get_section_params
def get_section_params(section):
section_params = {}
section_params['section'] = section
if section == SECTIONS.TV:
section_params['next_mode'] = MODES.SEASONS
section_params['folder'] = True
section_params['video_type'] = VIDEO_TYPES.TVSHOW
section_params['content_type'] = CONTENT_TYPES.TVSHOWS
section_params['search_img'] = 'television_search.png'
section_params['label_plural'] = i18n('tv_shows')
section_params['label_single'] = i18n('tv_show')
else:
section_params['next_mode'] = MODES.GET_SOURCES
section_params['folder'] = kodi.get_setting('source-win') == 'Directory' and kodi.get_setting('auto-play') == 'false'
section_params['video_type'] = VIDEO_TYPES.MOVIE
section_params['content_type'] = CONTENT_TYPES.MOVIES
section_params['search_img'] = 'movies_search.png'
section_params['label_plural'] = i18n('movies')
section_params['label_single'] = i18n('movie')
return section_params
示例9: perform_auto_conf
def perform_auto_conf(responses):
length = len(responses)
TOTAL = 12
if length < TOTAL:
responses += [True] * (TOTAL - length)
if responses[0]: kodi.set_setting('trakt_timeout', '60')
if responses[1]: kodi.set_setting('calendar-day', '-1')
if responses[2]: kodi.set_setting('calendar_time', '2')
if responses[3]: kodi.set_setting('source_timeout', '20')
if responses[4]: kodi.set_setting('include_watchlist_next', 'true')
if responses[5]: kodi.set_setting('filter_direct', 'true')
if responses[6]: kodi.set_setting('filter_unusable', 'true')
if responses[7]: kodi.set_setting('show_debrid', 'true')
if responses[8]: kodi.set_setting('source_results', '0')
if responses[9]:
kodi.set_setting('enable_sort', 'true')
kodi.set_setting('sort1_field', '2')
kodi.set_setting('sort2_field', '5')
kodi.set_setting('sort3_field', '6')
kodi.set_setting('sort4_field', '1')
kodi.set_setting('sort5_field', '3')
kodi.set_setting('sort6_field', '4')
if responses[10]:
tiers = ['Local', 'Furk.net', 'Premiumize.me', 'EasyNews', 'DD.tv', 'NoobRoom',
['WatchHD', 'IFlix', 'MoviesPlanet', 'CyberReel', '9Movies', '123Movies', 'niter.tv', 'ororo.tv'],
['movietv.to', 'StreamLord', 'tunemovie', 'afdah.org', 'xmovies8', 'xmovies8.v2', 'alluc.com'],
['torba.se', 'IzlemeyeDeger', 'Rainierland', 'zumvo.com', 'PutMV', 'MiraDeTodo', 'beinmovie'],
['SezonLukDizi', 'Dizimag', 'Dizilab', 'Dizigold', 'Diziay', 'Dizipas', 'OneClickTVShows'],
['DDLValley', 'ReleaseBB', 'MyVideoLinks.eu', 'OCW', 'RLSSource.net', 'TVRelease.Net'],
['IceFilms', 'PrimeWire', 'Flixanity', 'wso.ch', 'WatchSeries', 'UFlix.org', 'Putlocker', 'MovieHut'],
['funtastic-vids', 'WatchFree.to', 'pftv', 'streamallthis.is', 'Movie4K', 'afdah', 'SolarMovie', 'yify-streaming'],
['CouchTunerV2', 'CouchTunerV1', 'Watch8Now', 'yshows', 'TwoMovies.us', 'iWatchOnline', 'vidics.ch', 'pubfilm'],
['OnlineMoviesIs', 'OnlineMoviesPro', 'ViewMovies', 'movie25', 'viooz.ac', 'view47', 'MoviesHD', 'wmo.ch'],
['ayyex', 'stream-tv.co', 'clickplay.to', 'MintMovies', 'MovieNight', 'cmz', 'ch131', 'filmikz.ch'],
['MovieTube', 'LosMovies', 'FilmStreaming.in', 'moviestorm.eu', 'MerDB'],
'MoviesOnline7']
sso = []
random_sso = kodi.get_setting('random_sso') == 'true'
for tier in tiers:
if isinstance(tier, basestring):
sso.append(tier)
else:
if random_sso:
random.shuffle(tier)
sso += tier
kodi.set_setting('source_sort_order', '|'.join(sso))
if responses[11]: reset_base_url()
kodi.set_setting('filter-unknown', 'false')
kodi.notify(msg=i18n('auto_conf_complete'))
示例10: parallel_get_url
def parallel_get_url(q, scraper, video):
worker = threading.current_thread()
log_utils.log("Worker: %s (%s) for %s url" % (worker.name, worker, scraper.get_name()), log_utils.LOGDEBUG)
url = scraper.get_url(video)
log_utils.log("%s returned url %s from %s" % (scraper.get_name(), url, worker), log_utils.LOGDEBUG)
if not url:
url = ""
if url == FORCE_NO_MATCH:
label = "[%s] [COLOR green]%s[/COLOR]" % (scraper.get_name(), i18n("force_no_match"))
else:
label = "[%s] %s" % (scraper.get_name(), url)
related = {"class": scraper, "url": url, "name": scraper.get_name(), "label": label}
q.put(related)
示例11: do_disable_check
def do_disable_check():
auto_disable = kodi.get_setting("auto-disable")
disable_limit = int(kodi.get_setting("disable-limit"))
for cls in relevant_scrapers():
setting = "%s_last_results" % (cls.get_name())
fails = kodi.get_setting(setting)
fails = int(fails) if fails else 0
if fails >= disable_limit:
if auto_disable == DISABLE_SETTINGS.ON:
kodi.set_setting("%s-enable" % (cls.get_name()), "false")
kodi.notify(msg="[COLOR blue]%s[/COLOR] %s" % (cls.get_name(), i18n("scraper_disabled")), duration=5000)
kodi.set_setting(setting, "0")
elif auto_disable == DISABLE_SETTINGS.PROMPT:
dialog = xbmcgui.Dialog()
line1 = i18n("disable_line1") % (cls.get_name(), fails)
line2 = i18n("disable_line2")
line3 = i18n("disable_line3")
ret = dialog.yesno("SALTS", line1, line2, line3, i18n("keep_enabled"), i18n("disable_it"))
if ret:
kodi.set_setting("%s-enable" % (cls.get_name()), "false")
kodi.set_setting(setting, "0")
else:
kodi.set_setting(setting, "-1")
示例12: get_section_params
def get_section_params(section):
section_params = {}
section_params["section"] = section
if section == SECTIONS.TV:
section_params["next_mode"] = MODES.SEASONS
section_params["folder"] = True
section_params["video_type"] = VIDEO_TYPES.TVSHOW
section_params["content_type"] = CONTENT_TYPES.TVSHOWS
section_params["search_img"] = "television_search.png"
section_params["label_plural"] = i18n("tv_shows")
section_params["label_single"] = i18n("tv_show")
else:
section_params["next_mode"] = MODES.GET_SOURCES
section_params["folder"] = (
kodi.get_setting("source-win") == "Directory" and kodi.get_setting("auto-play") == "false"
)
section_params["video_type"] = VIDEO_TYPES.MOVIE
section_params["content_type"] = CONTENT_TYPES.MOVIES
section_params["search_img"] = "movies_search.png"
section_params["label_plural"] = i18n("movies")
section_params["label_single"] = i18n("movie")
return section_params
示例13: __attempt_db_recovery
def __attempt_db_recovery(self):
self.__recovery = True
header = i18n('recovery_header')
if xbmcgui.Dialog().yesno(header, i18n('rec_mig_1'), i18n('rec_mig_2')):
try: self.init_database('0.0.0')
except Exception as e:
log_utils.log('DB Migration Failed: %s' % (e), log_utils.LOGWARNING)
if xbmcgui.Dialog().yesno(header, i18n('rec_reset_1'), i18n('rec_reset_2'), i18n('rec_reset_3')):
try: result = self.reset_db()
except Exception as e:
log_utils.log('Reset Failed: %s' % (e), log_utils.LOGWARNING)
kodi.notify(msg=i18n('reset_failed') % e, duration=5000)
else:
if result:
kodi.notify(msg=i18n('db_reset_success'))
示例14: attempt_db_recovery
def attempt_db_recovery(self):
header = i18n('recovery_header')
if xbmcgui.Dialog().yesno(header, i18n('rec_mig_1'), i18n('rec_mig_2')):
try: self.init_database('0.0.0')
except Exception as e:
log_utils.log('DB Migration Failed: %s' % (e), log_utils.LOGWARNING)
if self.db_type == DB_TYPES.SQLITE:
if xbmcgui.Dialog().yesno(header, i18n('rec_reset_1'), i18n('rec_reset_2'), i18n('rec_reset_3')):
try: self.reset_db()
except Exception as e:
log_utils.log('Reset Failed: %s' % (e), log_utils.LOGWARNING)
try: msg = i18n('reset_failed') % (e)
except: msg = 'Reset Failed: %s' % (e)
else:
msg = i18n('db_reset_success')
kodi.notify(msg=msg, duration=5000)
示例15: download_media
def download_media(url, path, file_name):
try:
progress = int(ADDON.get_setting('down_progress'))
import urllib2
request = urllib2.Request(url)
request.add_header('User-Agent', USER_AGENT)
request.add_unredirected_header('Host', request.get_host())
response = urllib2.urlopen(request)
content_length = 0
if 'Content-Length' in response.info():
content_length = int(response.info()['Content-Length'])
file_name = file_name.replace('.strm', get_extension(url, response))
full_path = os.path.join(path, file_name)
log_utils.log('Downloading: %s -> %s' % (url, full_path), xbmc.LOGDEBUG)
path = xbmc.makeLegalFilename(path)
if not xbmcvfs.exists(path):
try:
try: xbmcvfs.mkdirs(path)
except: os.mkdir(path)
except Exception as e:
raise Exception(i18n('failed_create_dir'))
file_desc = xbmcvfs.File(full_path, 'w')
total_len = 0
if progress:
if progress == PROGRESS.WINDOW:
dialog = xbmcgui.DialogProgress()
else:
dialog = xbmcgui.DialogProgressBG()
dialog.create('Stream All The Sources', i18n('downloading') % (file_name))
dialog.update(0)
while True:
data = response.read(CHUNK_SIZE)
if not data:
break
if progress == PROGRESS.WINDOW and dialog.iscanceled():
break
total_len += len(data)
if not file_desc.write(data):
raise Exception('failed_write_file')
percent_progress = (total_len) * 100 / content_length if content_length > 0 else 0
log_utils.log('Position : %s / %s = %s%%' % (total_len, content_length, percent_progress), xbmc.LOGDEBUG)
if progress == PROGRESS.WINDOW:
dialog.update(percent_progress)
elif progress == PROGRESS.BACKGROUND:
dialog.update(percent_progress, 'Stream All The Sources')
else:
notify(msg=i18n('download_complete') % (file_name), duration=5000)
log_utils.log('Download Complete: %s -> %s' % (url, full_path), xbmc.LOGDEBUG)
file_desc.close()
if progress:
dialog.close()
except Exception as e:
log_utils.log('Error (%s) during download: %s -> %s' % (str(e), url, file_name), xbmc.LOGERROR)
notify(msg=i18n('download_error') % (str(e), file_name), duration=5000)