Change translation function name from _ to translate

This commit is contained in:
TrueTechy 2019-11-25 00:41:37 +00:00
parent 8f572ec313
commit 4e179890ec
22 changed files with 195 additions and 195 deletions

View file

@ -9,7 +9,7 @@ import xbmc
import xbmcaddon
import xbmcvfs
from helper import _, window, settings, addon_id, dialog
from helper import translate, window, settings, addon_id, dialog
from helper.utils import create_id
##################################################################################################
@ -114,7 +114,7 @@ def reset_device_id():
window('jellyfin_deviceId', clear=True)
get_device_id(True)
dialog("ok", heading="{jellyfin}", line1=_(33033))
dialog("ok", heading="{jellyfin}", line1=translate(33033))
xbmc.executebuiltin('RestartApp')

View file

@ -12,7 +12,7 @@ import xbmc
import xbmcvfs
import jellyfin_db
from helper import _, settings, window, dialog
from helper import translate, settings, window, dialog
from objects import obj
#################################################################################################
@ -215,7 +215,7 @@ def reset():
from views import Views
views = Views()
if not dialog("yesno", heading="{jellyfin}", line1=_(33074)):
if not dialog("yesno", heading="{jellyfin}", line1=translate(33074)):
return
window('jellyfin_should_stop.bool', True)
@ -227,7 +227,7 @@ def reset():
count -= 1
if not count:
dialog("ok", heading="{jellyfin}", line1=_(33085))
dialog("ok", heading="{jellyfin}", line1=translate(33085))
return
@ -239,12 +239,12 @@ def reset():
views.delete_playlists()
views.delete_nodes()
if dialog("yesno", heading="{jellyfin}", line1=_(33086)):
if dialog("yesno", heading="{jellyfin}", line1=translate(33086)):
reset_artwork()
addon_data = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/").decode('utf-8')
if dialog("yesno", heading="{jellyfin}", line1=_(33087)):
if dialog("yesno", heading="{jellyfin}", line1=translate(33087)):
xbmcvfs.delete(os.path.join(addon_data, "settings.xml"))
xbmcvfs.delete(os.path.join(addon_data, "data.json"))
@ -257,7 +257,7 @@ def reset():
settings('MinimumSetup', "")
settings('MusicRescan.bool', False)
settings('SyncInstallRunDone.bool', False)
dialog("ok", heading="{jellyfin}", line1=_(33088))
dialog("ok", heading="{jellyfin}", line1=translate(33088))
xbmc.executebuiltin('RestartApp')
@ -272,7 +272,7 @@ def reset_kodi():
if name != 'version':
videodb.cursor.execute("DELETE FROM " + name)
if settings('enableMusic.bool') or dialog("yesno", heading="{jellyfin}", line1=_(33162)):
if settings('enableMusic.bool') or dialog("yesno", heading="{jellyfin}", line1=translate(33162)):
with Database('music') as musicdb:
musicdb.cursor.execute("SELECT tbl_name FROM sqlite_master WHERE type='table'")

View file

@ -8,7 +8,7 @@ import os
import xbmcgui
import xbmcaddon
from helper import _, addon_id
from helper import translate, addon_id
##################################################################################################
@ -78,7 +78,7 @@ class LoginManual(xbmcgui.WindowXMLDialog):
if not user:
# Display error
self._error(ERROR['Empty'], _('empty_user'))
self._error(ERROR['Empty'], translate('empty_user'))
LOG.error("Username cannot be null")
elif self._login(user, password):
@ -121,7 +121,7 @@ class LoginManual(xbmcgui.WindowXMLDialog):
result = self.connect_manager.login(server, username, password)
if not result:
self._error(ERROR['Invalid'], _('invalid_auth'))
self._error(ERROR['Invalid'], translate('invalid_auth'))
return False
else:
self._user = result

View file

@ -7,7 +7,7 @@ import logging
import xbmc
import xbmcgui
from helper import _
from helper import translate
from jellyfin.connection_manager import CONNECTION_STATE
##################################################################################################
@ -110,7 +110,7 @@ class ServerConnect(xbmcgui.WindowXMLDialog):
def _connect_server(self, server_id):
server = self.connect_manager.get_server_info(server_id)
self.message.setLabel("%s %s..." % (_(30610), server['Name']))
self.message.setLabel("%s %s..." % (translate(30610), server['Name']))
self.message_box.setVisibleCondition('true')
self.busy.setVisibleCondition('true')
@ -120,7 +120,7 @@ class ServerConnect(xbmcgui.WindowXMLDialog):
if result['State'] == CONNECTION_STATE['Unavailable']:
self.busy.setVisibleCondition('false')
self.message.setLabel(_(30609))
self.message.setLabel(translate(30609))
return False
else:
xbmc.sleep(1000)

View file

@ -9,7 +9,7 @@ import re
import xbmcgui
import xbmcaddon
from helper import _, addon_id
from helper import translate, addon_id
from jellyfin.connection_manager import CONNECTION_STATE
##################################################################################################
@ -77,7 +77,7 @@ class ServerManual(xbmcgui.WindowXMLDialog):
if not server:
# Display error
self._error(ERROR['Empty'], _('empty_server'))
self._error(ERROR['Empty'], translate('empty_server'))
LOG.error("Server cannot be null")
elif self._connect_to_server(server):
@ -116,11 +116,11 @@ class ServerManual(xbmcgui.WindowXMLDialog):
if _IPV6_RE.match(server):
server = "[%s]" % (server)
self._message("%s %s..." % (_(30610), server))
self._message("%s %s..." % (translate(30610), server))
result = self.connect_manager.connect_to_address(server)
if result['State'] == CONNECTION_STATE['Unavailable']:
self._message(_(30609))
self._message(translate(30609))
return False
else:
self._server = result['Servers'][0]

View file

@ -11,7 +11,7 @@ import xbmcaddon
import database
from dialogs import context
from helper import _, settings, dialog
from helper import translate, settings, dialog
from downloader import TheVoid
#################################################################################################
@ -19,12 +19,12 @@ from downloader import TheVoid
LOG = logging.getLogger("JELLYFIN." + __name__)
XML_PATH = (xbmcaddon.Addon('plugin.video.jellyfin').getAddonInfo('path'), "default", "1080i")
OPTIONS = {
'Refresh': _(30410),
'Delete': _(30409),
'Addon': _(30408),
'AddFav': _(30405),
'RemoveFav': _(30406),
'Transcode': _(30412)
'Refresh': translate(30410),
'Delete': translate(30409),
'Addon': translate(30408),
'AddFav': translate(30405),
'RemoveFav': translate(30406),
'Transcode': translate(30412)
}
#################################################################################################
@ -163,7 +163,7 @@ class Context(object):
if not settings('skipContextMenu.bool'):
if not dialog("yesno", heading="{jellyfin}", line1=_(33015)):
if not dialog("yesno", heading="{jellyfin}", line1=translate(33015)):
delete = False
if delete:

View file

@ -19,7 +19,7 @@ import client
from database import reset, get_sync, Database, jellyfin_db, get_credentials
from objects import Objects, Actions
from downloader import TheVoid
from helper import _, event, settings, window, dialog, api, JSONRPC
from helper import translate, event, settings, window, dialog, api, JSONRPC
#################################################################################################
@ -146,14 +146,14 @@ def listing():
context = []
if view_id and node in ('movies', 'tvshows', 'musicvideos', 'music', 'mixed') and view_id not in whitelist:
label = "%s %s" % (label.decode('utf-8'), _(33166))
context.append((_(33123), "RunPlugin(plugin://plugin.video.jellyfin/?mode=synclib&id=%s)" % view_id))
label = "%s %s" % (label.decode('utf-8'), translate(33166))
context.append((translate(33123), "RunPlugin(plugin://plugin.video.jellyfin/?mode=synclib&id=%s)" % view_id))
if view_id and node in ('movies', 'tvshows', 'musicvideos', 'music') and view_id in whitelist:
context.append((_(33136), "RunPlugin(plugin://plugin.video.jellyfin/?mode=updatelib&id=%s)" % view_id))
context.append((_(33132), "RunPlugin(plugin://plugin.video.jellyfin/?mode=repairlib&id=%s)" % view_id))
context.append((_(33133), "RunPlugin(plugin://plugin.video.jellyfin/?mode=removelib&id=%s)" % view_id))
context.append((translate(33136), "RunPlugin(plugin://plugin.video.jellyfin/?mode=updatelib&id=%s)" % view_id))
context.append((translate(33132), "RunPlugin(plugin://plugin.video.jellyfin/?mode=repairlib&id=%s)" % view_id))
context.append((translate(33133), "RunPlugin(plugin://plugin.video.jellyfin/?mode=removelib&id=%s)" % view_id))
LOG.debug("--[ listing/%s/%s ] %s", node, label, path)
@ -171,22 +171,22 @@ def listing():
context = []
if server.get('ManualAddress'):
context.append((_(33141), "RunPlugin(plugin://plugin.video.jellyfin/?mode=removeserver&server=%s)" % server['Id']))
context.append((translate(33141), "RunPlugin(plugin://plugin.video.jellyfin/?mode=removeserver&server=%s)" % server['Id']))
if 'AccessToken' not in server:
directory("%s (%s)" % (server['Name'], _(30539)), "plugin://plugin.video.jellyfin/?mode=login&server=%s" % server['Id'], False, context=context)
directory("%s (%s)" % (server['Name'], translate(30539)), "plugin://plugin.video.jellyfin/?mode=login&server=%s" % server['Id'], False, context=context)
else:
directory(server['Name'], "plugin://plugin.video.jellyfin/?mode=browse&server=%s" % server['Id'], context=context)
directory(_(33194), "plugin://plugin.video.jellyfin/?mode=managelibs", True)
directory(_(33134), "plugin://plugin.video.jellyfin/?mode=addserver", False)
directory(_(33054), "plugin://plugin.video.jellyfin/?mode=adduser", False)
directory(_(5), "plugin://plugin.video.jellyfin/?mode=settings", False)
directory(_(33058), "plugin://plugin.video.jellyfin/?mode=reset", False)
directory(_(33192), "plugin://plugin.video.jellyfin/?mode=restartservice", False)
directory(translate(33194), "plugin://plugin.video.jellyfin/?mode=managelibs", True)
directory(translate(33134), "plugin://plugin.video.jellyfin/?mode=addserver", False)
directory(translate(33054), "plugin://plugin.video.jellyfin/?mode=adduser", False)
directory(translate(5), "plugin://plugin.video.jellyfin/?mode=settings", False)
directory(translate(33058), "plugin://plugin.video.jellyfin/?mode=reset", False)
directory(translate(33192), "plugin://plugin.video.jellyfin/?mode=restartservice", False)
if settings('backupPath'):
directory(_(33092), "plugin://plugin.video.jellyfin/?mode=backup", False)
directory(translate(33092), "plugin://plugin.video.jellyfin/?mode=backup", False)
xbmcplugin.setContent(int(sys.argv[1]), 'files')
xbmcplugin.endOfDirectory(int(sys.argv[1]))
@ -220,12 +220,12 @@ def dir_listitem(label, path, artwork=None, fanart=None):
def manage_libraries():
directory(_(33098), "plugin://plugin.video.jellyfin/?mode=refreshboxsets", False)
directory(_(33154), "plugin://plugin.video.jellyfin/?mode=addlibs", False)
directory(_(33139), "plugin://plugin.video.jellyfin/?mode=updatelibs", False)
directory(_(33140), "plugin://plugin.video.jellyfin/?mode=repairlibs", False)
directory(_(33184), "plugin://plugin.video.jellyfin/?mode=removelibs", False)
directory(_(33060), "plugin://plugin.video.jellyfin/?mode=thememedia", False)
directory(translate(33098), "plugin://plugin.video.jellyfin/?mode=refreshboxsets", False)
directory(translate(33154), "plugin://plugin.video.jellyfin/?mode=addlibs", False)
directory(translate(33139), "plugin://plugin.video.jellyfin/?mode=updatelibs", False)
directory(translate(33140), "plugin://plugin.video.jellyfin/?mode=repairlibs", False)
directory(translate(33184), "plugin://plugin.video.jellyfin/?mode=removelibs", False)
directory(translate(33060), "plugin://plugin.video.jellyfin/?mode=thememedia", False)
xbmcplugin.setContent(int(sys.argv[1]), 'files')
xbmcplugin.endOfDirectory(int(sys.argv[1]))
@ -345,9 +345,9 @@ def browse(media, view_id=None, folder=None, server_id=None):
context.append(("Play", "RunPlugin(plugin://plugin.video.jellyfin/?mode=playlist&id=%s&server=%s)" % (item['Id'], server_id)))
if item['UserData']['Played']:
context.append((_(16104), "RunPlugin(plugin://plugin.video.jellyfin/?mode=unwatched&id=%s&server=%s)" % (item['Id'], server_id)))
context.append((translate(16104), "RunPlugin(plugin://plugin.video.jellyfin/?mode=unwatched&id=%s&server=%s)" % (item['Id'], server_id)))
else:
context.append((_(16103), "RunPlugin(plugin://plugin.video.jellyfin/?mode=watched&id=%s&server=%s)" % (item['Id'], server_id)))
context.append((translate(16103), "RunPlugin(plugin://plugin.video.jellyfin/?mode=watched&id=%s&server=%s)" % (item['Id'], server_id)))
li.addContextMenuItems(context)
list_li.append((path, li, True))
@ -373,12 +373,12 @@ def browse(media, view_id=None, folder=None, server_id=None):
}
path = "%s?%s" % ("plugin://plugin.video.jellyfin/", urllib.urlencode(params))
li.setProperty('path', path)
context = [(_(13412), "RunPlugin(plugin://plugin.video.jellyfin/?mode=playlist&id=%s&server=%s)" % (item['Id'], server_id))]
context = [(translate(13412), "RunPlugin(plugin://plugin.video.jellyfin/?mode=playlist&id=%s&server=%s)" % (item['Id'], server_id))]
if item['UserData']['Played']:
context.append((_(16104), "RunPlugin(plugin://plugin.video.jellyfin/?mode=unwatched&id=%s&server=%s)" % (item['Id'], server_id)))
context.append((translate(16104), "RunPlugin(plugin://plugin.video.jellyfin/?mode=unwatched&id=%s&server=%s)" % (item['Id'], server_id)))
else:
context.append((_(16103), "RunPlugin(plugin://plugin.video.jellyfin/?mode=watched&id=%s&server=%s)" % (item['Id'], server_id)))
context.append((translate(16103), "RunPlugin(plugin://plugin.video.jellyfin/?mode=watched&id=%s&server=%s)" % (item['Id'], server_id)))
li.addContextMenuItems(context)
@ -740,14 +740,14 @@ def add_user():
users = TheVoid('GetUsers', {'IsDisabled': False, 'IsHidden': False}).get()
current = session[0]['AdditionalUsers']
result = dialog("select", _(33061), [_(33062), _(33063)] if current else [_(33062)])
result = dialog("select", translate(33061), [translate(33062), translate(33063)] if current else [translate(33062)])
if result < 0:
return
if not result: # Add user
eligible = [x for x in users if x['Id'] not in [current_user['UserId'] for current_user in current]]
resp = dialog("select", _(33064), [x['Name'] for x in eligible])
resp = dialog("select", translate(33064), [x['Name'] for x in eligible])
if resp < 0:
return
@ -755,7 +755,7 @@ def add_user():
user = eligible[resp]
event('AddUser', {'Id': user['Id'], 'Add': True})
else: # Remove user
resp = dialog("select", _(33064), [x['UserName'] for x in current])
resp = dialog("select", translate(33064), [x['UserName'] for x in current])
if resp < 0:
return
@ -786,7 +786,7 @@ def get_themes():
tvtunes.setSetting('custom_path', library)
LOG.info("TV Tunes custom path is enabled and set.")
else:
dialog("ok", heading="{jellyfin}", line1=_(33152))
dialog("ok", heading="{jellyfin}", line1=translate(33152))
return
@ -834,7 +834,7 @@ def get_themes():
tvtunes_nfo(nfo_file, paths)
dialog("notification", heading="{jellyfin}", message=_(33153), icon="{jellyfin}", time=1000, sound=False)
dialog("notification", heading="{jellyfin}", message=translate(33153), icon="{jellyfin}", time=1000, sound=False)
def delete_item():
@ -854,7 +854,7 @@ def backup():
path = settings('backupPath')
folder_name = "Kodi%s.%s" % (xbmc.getInfoLabel('System.BuildVersion')[:2], xbmc.getInfoLabel('System.Date(dd-mm-yy)'))
folder_name = dialog("input", heading=_(33089), defaultt=folder_name)
folder_name = dialog("input", heading=translate(33089), defaultt=folder_name)
if not folder_name:
return
@ -862,7 +862,7 @@ def backup():
backup = os.path.join(path, folder_name)
if xbmcvfs.exists(backup + '/'):
if not dialog("yesno", heading="{jellyfin}", line1=_(33090)):
if not dialog("yesno", heading="{jellyfin}", line1=translate(33090)):
return backup()
@ -875,7 +875,7 @@ def backup():
if not xbmcvfs.mkdirs(path) or not xbmcvfs.mkdirs(destination_databases):
LOG.info("Unable to create all directories")
dialog("notification", heading="{jellyfin}", icon="{jellyfin}", message=_(33165), sound=False)
dialog("notification", heading="{jellyfin}", icon="{jellyfin}", message=translate(33165), sound=False)
return
@ -900,4 +900,4 @@ def backup():
LOG.info("copied %s", filename)
LOG.info("backup completed")
dialog("ok", heading="{jellyfin}", line1="%s %s" % (_(33091), backup))
dialog("ok", heading="{jellyfin}", line1="%s %s" % (translate(33091), backup))

View file

@ -19,7 +19,7 @@ import library
import setup
import monitor
from views import Views, verify_kodi_defaults
from helper import _, window, settings, event, dialog
from helper import translate, window, settings, event, dialog
from jellyfin import Jellyfin
#################################################################################################
@ -116,7 +116,7 @@ class Service(xbmc.Monitor):
if window('jellyfin.restart.bool'):
window('jellyfin.restart', clear=True)
dialog("notification", heading="{jellyfin}", message=_(33193), icon="{jellyfin}", time=1000, sound=False)
dialog("notification", heading="{jellyfin}", message=translate(33193), icon="{jellyfin}", time=1000, sound=False)
raise Exception('RestartService')
@ -183,7 +183,7 @@ class Service(xbmc.Monitor):
users = [user for user in (settings('additionalUsers') or "").decode('utf-8').split(',') if user]
users.insert(0, settings('username').decode('utf-8'))
dialog("notification", heading="{jellyfin}", message="%s %s" % (_(33000), ", ".join(users)),
dialog("notification", heading="{jellyfin}", message="%s %s" % (translate(33000), ", ".join(users)),
icon="{jellyfin}", time=1500, sound=False)
if self.library_thread is None:
@ -196,7 +196,7 @@ class Service(xbmc.Monitor):
if self.warn or data.get('ServerId'):
self.warn = data.get('ServerId') is not None
dialog("notification", heading="{jellyfin}", message=_(33146) if data.get('ServerId') is None else _(33149), icon=xbmcgui.NOTIFICATION_ERROR)
dialog("notification", heading="{jellyfin}", message=translate(33146) if data.get('ServerId') is None else translate(33149), icon=xbmcgui.NOTIFICATION_ERROR)
if data.get('ServerId') is None:
self.stop_default()
@ -207,7 +207,7 @@ class Service(xbmc.Monitor):
self.start_default()
elif method == 'Unauthorized':
dialog("notification", heading="{jellyfin}", message=_(33147) if data['ServerId'] is None else _(33148), icon=xbmcgui.NOTIFICATION_ERROR)
dialog("notification", heading="{jellyfin}", message=translate(33147) if data['ServerId'] is None else translate(33148), icon=xbmcgui.NOTIFICATION_ERROR)
if data.get('ServerId') is None and self.settings['auth_check']:
@ -224,7 +224,7 @@ class Service(xbmc.Monitor):
return
if settings('restartMsg.bool'):
dialog("notification", heading="{jellyfin}", message=_(33006), icon="{jellyfin}")
dialog("notification", heading="{jellyfin}", message=translate(33006), icon="{jellyfin}")
self.stop_default()
@ -249,7 +249,7 @@ class Service(xbmc.Monitor):
elif method == 'UpdateServer':
dialog("ok", heading="{jellyfin}", line1=_(33151))
dialog("ok", heading="{jellyfin}", line1=translate(33151))
self.connect.setup_manual_server()
elif method == 'UserDataChanged' and self.library_thread:
@ -383,13 +383,13 @@ class Service(xbmc.Monitor):
if not self.settings.get('mode_warn'):
self.settings['mode_warn'] = True
dialog("yesno", heading="{jellyfin}", line1=_(33118))
dialog("yesno", heading="{jellyfin}", line1=translate(33118))
if settings('kodiCompanion.bool') != self.settings['kodi_companion']:
self.settings['kodi_companion'] = settings('kodiCompanion.bool')
if not self.settings['kodi_companion']:
dialog("ok", heading="{jellyfin}", line1=_(33138))
dialog("ok", heading="{jellyfin}", line1=translate(33138))
def reload_objects(self):

View file

@ -10,7 +10,7 @@ import xbmc
import downloader as server
import helper.xmls as xmls
from database import Database, get_sync, save_sync, jellyfin_db
from helper import _, settings, window, progress, dialog, LibraryException
from helper import translate, settings, window, progress, dialog, LibraryException
from helper.utils import get_screensaver, set_screensaver
##################################################################################################
@ -40,7 +40,7 @@ class FullSync(object):
self.__dict__ = self._shared_state
if self.running:
dialog("ok", heading="{jellyfin}", line1=_(33197))
dialog("ok", heading="{jellyfin}", line1=translate(33197))
raise Exception("Sync is already running.")
@ -111,10 +111,10 @@ class FullSync(object):
'''
if self.sync['Libraries']:
if not dialog("yesno", heading="{jellyfin}", line1=_(33102)):
if not dialog("yesno", heading="{jellyfin}", line1=translate(33102)):
if not dialog("yesno", heading="{jellyfin}", line1=_(33173)):
dialog("ok", heading="{jellyfin}", line1=_(33122))
if not dialog("yesno", heading="{jellyfin}", line1=translate(33173)):
dialog("ok", heading="{jellyfin}", line1=translate(33122))
raise LibraryException("ProgressStopped")
else:
@ -142,8 +142,8 @@ class FullSync(object):
'''
choices = [x['Name'] for x in libraries]
choices.insert(0, _(33121))
selection = dialog("multi", _(33120), choices)
choices.insert(0, translate(33121))
selection = dialog("multi", translate(33120), choices)
if selection is None:
raise LibraryException('LibrarySelection')
@ -193,7 +193,7 @@ class FullSync(object):
save_sync(self.sync)
xbmc.executebuiltin('UpdateLibrary(video)')
dialog("notification", heading="{jellyfin}", message="%s %s" % (_(33025), str(elapsed).split('.')[0]),
dialog("notification", heading="{jellyfin}", message="%s %s" % (translate(33025), str(elapsed).split('.')[0]),
icon="{jellyfin}", sound=False)
LOG.info("Full sync completed in: %s", str(elapsed).split('.')[0])
@ -241,7 +241,7 @@ class FullSync(object):
if 'Failed to validate path' not in error:
dialog("ok", heading="{jellyfin}", line1=_(33119))
dialog("ok", heading="{jellyfin}", line1=translate(33119))
LOG.error("full sync exited unexpectedly")
save_sync(self.sync)
@ -268,7 +268,7 @@ class FullSync(object):
for index, movie in enumerate(items['Items']):
dialog.update(int((float(start_index + index) / float(items['TotalRecordCount'])) * 100),
heading="%s: %s" % (_('addon_name'), library['Name']),
heading="%s: %s" % (translate('addon_name'), library['Name']),
message=movie['Name'])
obj.movie(movie, library=library)
@ -309,7 +309,7 @@ class FullSync(object):
percent = int((float(start_index + index) / float(items['TotalRecordCount'])) * 100)
message = show['Name']
dialog.update(percent, heading="%s: %s" % (_('addon_name'), library['Name']), message=message)
dialog.update(percent, heading="%s: %s" % (translate('addon_name'), library['Name']), message=message)
if obj.tvshow(show, library=library) is not False:
@ -358,7 +358,7 @@ class FullSync(object):
for index, mvideo in enumerate(items['Items']):
dialog.update(int((float(start_index + index) / float(items['TotalRecordCount'])) * 100),
heading="%s: %s" % (_('addon_name'), library['Name']),
heading="%s: %s" % (translate('addon_name'), library['Name']),
message=mvideo['Name'])
obj.musicvideo(mvideo, library=library)
@ -399,7 +399,7 @@ class FullSync(object):
percent = int((float(start_index + index) / float(items['TotalRecordCount'])) * 100)
message = artist['Name']
dialog.update(percent, heading="%s: %s" % (_('addon_name'), library['Name']), message=message)
dialog.update(percent, heading="%s: %s" % (translate('addon_name'), library['Name']), message=message)
obj.artist(artist, library=library)
for albums in server.get_albums_by_artist(artist['Id']):
@ -439,7 +439,7 @@ class FullSync(object):
if x[0] not in current and x[1] == 'MusicArtist':
obj.remove(x[0])
@progress(_(33018))
@progress(translate(33018))
def boxsets(self, library_id=None, dialog=None):
''' Process all boxsets.
@ -459,7 +459,7 @@ class FullSync(object):
for index, boxset in enumerate(items['Items']):
dialog.update(int((float(start_index + index) / float(items['TotalRecordCount'])) * 100),
heading="%s: %s" % (_('addon_name'), _('boxsets')),
heading="%s: %s" % (translate('addon_name'), translate('boxsets')),
message=boxset['Name'])
obj.boxset(boxset)
@ -478,7 +478,7 @@ class FullSync(object):
self.boxsets(None)
@progress(_(33144))
@progress(translate(33144))
def remove_library(self, library_id, dialog):
''' Remove library by their id from the Kodi database.
@ -512,7 +512,7 @@ class FullSync(object):
for item in movies:
obj(item[0])
dialog.update(int((float(count) / float(len(items)) * 100)), heading="%s: %s" % (_('addon_name'), library[0]))
dialog.update(int((float(count) / float(len(items)) * 100)), heading="%s: %s" % (translate('addon_name'), library[0]))
count += 1
obj = TVShows(self.server, jellyfindb, kodidb, direct_path).remove
@ -520,7 +520,7 @@ class FullSync(object):
for item in tvshows:
obj(item[0])
dialog.update(int((float(count) / float(len(items)) * 100)), heading="%s: %s" % (_('addon_name'), library[0]))
dialog.update(int((float(count) / float(len(items)) * 100)), heading="%s: %s" % (translate('addon_name'), library[0]))
count += 1
else:
# from mcarlton: I'm not sure what triggers this.
@ -535,7 +535,7 @@ class FullSync(object):
for item in items:
obj(item[0])
dialog.update(int((float(count) / float(len(items)) * 100)), heading="%s: %s" % (_('addon_name'), library[0]))
dialog.update(int((float(count) / float(len(items)) * 100)), heading="%s: %s" % (translate('addon_name'), library[0]))
count += 1
self.sync = get_sync()

View file

@ -1,4 +1,4 @@
from translate import _
from translate import translate
from exceptions import LibraryException
from utils import addon_id

View file

@ -15,7 +15,7 @@ import client
import requests
from downloader import TheVoid
from . import _, settings, window, dialog
from . import translate, settings, window, dialog
#################################################################################################
@ -111,7 +111,7 @@ class PlayUtils(object):
for source in sources:
selection.append(source.get('Name', "na"))
resp = dialog("select", _(33130), selection)
resp = dialog("select", translate(33130), selection)
if resp > -1:
source = sources[resp]
@ -581,7 +581,7 @@ class PlayUtils(object):
if len(audio_streams) > 1:
selection = list(audio_streams.keys())
resp = dialog("select", _(33013), selection)
resp = dialog("select", translate(33013), selection)
audio_selected = audio_streams[selection[resp]] if resp else source['DefaultAudioStreamIndex']
else: # Only one choice
audio_selected = audio_streams[next(iter(audio_streams))]
@ -608,7 +608,7 @@ class PlayUtils(object):
elif skip_dialog in (0, 2) and len(subs_streams):
selection = list(['No subtitles']) + list(subs_streams.keys())
resp = dialog("select", _(33014), selection)
resp = dialog("select", translate(33014), selection)
if resp:
index = subs_streams[selection[resp]] if resp > -1 else source.get('DefaultSubtitleStreamIndex')

View file

@ -14,7 +14,7 @@ LOG = logging.getLogger('JELLYFIN.' + __name__)
##################################################################################################
def _(string):
def translate(string):
''' Get add-on string. Returns in unicode.
'''

View file

@ -19,7 +19,7 @@ import xbmcaddon
import xbmcgui
import xbmcvfs
from translate import _
from translate import translate
#################################################################################################
@ -154,7 +154,7 @@ def dialog(dialog_type, *args, **kwargs):
"special://home/addons/plugin.video.jellyfin/resources/icon.png"
)
if "heading" in kwargs:
kwargs['heading'] = kwargs['heading'].replace("{jellyfin}", _('addon_name'))
kwargs['heading'] = kwargs['heading'].replace("{jellyfin}", translate('addon_name'))
types = {
'yesno': d.yesno,
@ -250,7 +250,7 @@ def validate(path):
if not xbmcvfs.exists(path):
LOG.info("Could not find %s", path)
if dialog("yesno", heading="{jellyfin}", line1="%s %s. %s" % (_(33047), path, _(33048))):
if dialog("yesno", heading="{jellyfin}", line1="%s %s. %s" % (translate(33047), path, translate(33048))):
return False

View file

@ -8,7 +8,7 @@ import xbmcgui
from .utils import should_stop
from .exceptions import LibraryException
from .translate import _
from .translate import translate
#################################################################################################
@ -28,10 +28,10 @@ def progress(message=None):
if item and type(item) == dict:
dialog.create(_('addon_name'), "%s %s" % (_('gathering'), item['Name']))
dialog.create(translate('addon_name'), "%s %s" % (translate('gathering'), item['Name']))
LOG.info("Processing %s: %s", item['Name'], item['Id'])
else:
dialog.create(_('addon_name'), message)
dialog.create(translate('addon_name'), message)
LOG.info("Processing %s", message)
if item:

View file

@ -8,7 +8,7 @@ import xml.etree.ElementTree as etree
import xbmc
from . import _, indent, write_xml, dialog, settings
from . import translate, indent, write_xml, dialog, settings
#################################################################################################
@ -127,7 +127,7 @@ def advanced_settings():
indent(xml)
write_xml(etree.tostring(xml, 'UTF-8'), path)
dialog("ok", heading="{jellyfin}", line1=_(33097))
dialog("ok", heading="{jellyfin}", line1=translate(33097))
xbmc.executebuiltin('RestartApp')
return True

View file

@ -15,7 +15,7 @@ from database import Database, jellyfin_db, get_sync, save_sync
from full_sync import FullSync
from views import Views
from downloader import GetItemWorker
from helper import _, api, stop, settings, window, dialog, event, LibraryException
from helper import translate, api, stop, settings, window, dialog, event, LibraryException
from helper.utils import split_list, set_screensaver, get_screensaver
from jellyfin import Jellyfin
@ -155,12 +155,12 @@ class Library(threading.Thread):
if self.progress_updates is None:
self.progress_updates = xbmcgui.DialogProgressBG()
self.progress_updates.create(_('addon_name'), _(33178))
self.progress_updates.update(int((float(self.total_updates - queue_size) / float(self.total_updates)) * 100), message="%s: %s" % (_(33178), queue_size))
self.progress_updates.create(translate('addon_name'), translate(33178))
self.progress_updates.update(int((float(self.total_updates - queue_size) / float(self.total_updates)) * 100), message="%s: %s" % (translate(33178), queue_size))
elif queue_size:
self.progress_updates.update(int((float(self.total_updates - queue_size) / float(self.total_updates)) * 100), message="%s: %s" % (_(33178), queue_size))
self.progress_updates.update(int((float(self.total_updates - queue_size) / float(self.total_updates)) * 100), message="%s: %s" % (translate(33178), queue_size))
else:
self.progress_updates.update(int((float(self.total_updates - queue_size) / float(self.total_updates)) * 100), message=_(33178))
self.progress_updates.update(int((float(self.total_updates - queue_size) / float(self.total_updates)) * 100), message=translate(33178))
if not settings('dbSyncScreensaver.bool') and self.screensaver is None:
@ -346,7 +346,7 @@ class Library(threading.Thread):
if self.server.jellyfin.check_companion_installed():
if not self.fast_sync():
dialog("ok", heading="{jellyfin}", line1=_(33128))
dialog("ok", heading="{jellyfin}", line1=translate(33128))
raise Exception("Failed to retrieve latest updates")
@ -361,7 +361,7 @@ class Library(threading.Thread):
if error.status in 'SyncLibraryLater':
dialog("ok", heading="{jellyfin}", line1=_(33129))
dialog("ok", heading="{jellyfin}", line1=translate(33129))
settings('SyncInstallRunDone.bool', True)
sync = get_sync()
sync['Libraries'] = []
@ -371,7 +371,7 @@ class Library(threading.Thread):
elif error.status == 'CompanionMissing':
dialog("ok", heading="{jellyfin}", line1=_(33099))
dialog("ok", heading="{jellyfin}", line1=translate(33099))
settings('kodiCompanion.bool', False)
return True
@ -414,7 +414,7 @@ class Library(threading.Thread):
''' Inverse yes no, in case the dialog is forced closed by Kodi.
'''
if dialog("yesno", heading="{jellyfin}", line1=_(33172).replace('{number}', str(total)), nolabel=_(107), yeslabel=_(106)):
if dialog("yesno", heading="{jellyfin}", line1=translate(33172).replace('{number}', str(total)), nolabel=translate(107), yeslabel=translate(106)):
LOG.warning("Large updates skipped.")
return True
@ -492,7 +492,7 @@ class Library(threading.Thread):
libraries.append({'Id': library, 'Name': name})
choices = [x['Name'] for x in libraries]
choices.insert(0, _(33121))
choices.insert(0, translate(33121))
titles = {
"RepairLibrarySelection": 33199,
@ -502,7 +502,7 @@ class Library(threading.Thread):
}
title = titles.get(mode, "Failed to get title {}".format(mode))
selection = dialog("multi", _(title), choices)
selection = dialog("multi", translate(title), choices)
if selection is None:
return
@ -820,7 +820,7 @@ class NotifyWorker(threading.Thread):
time = self.music_time if item[0] == 'Audio' else self.video_time
if time and (not self.player.isPlayingVideo() or xbmc.getCondVisibility('VideoPlayer.Content(livetv)')):
dialog("notification", heading="%s %s" % (_(33049), item[0]), message=item[1],
dialog("notification", heading="%s %s" % (translate(33049), item[0]), message=item[1],
icon="{jellyfin}", time=time, sound=False)
self.queue.task_done()

View file

@ -14,7 +14,7 @@ import downloader
import player
from client import get_device_id
from objects import PlaylistWorker, on_play, on_update, special_listener
from helper import _, settings, window, dialog, api, JSONRPC
from helper import translate, settings, window, dialog, api, JSONRPC
from jellyfin import Jellyfin
from webservice import WebService
@ -114,7 +114,7 @@ class Monitor(xbmc.Monitor):
except Exception as error:
LOG.exception(error)
dialog("ok", heading="{jellyfin}", line1=_(33142))
dialog("ok", heading="{jellyfin}", line1=translate(33142))
return

View file

@ -15,7 +15,7 @@ import xbmcaddon
import database
from downloader import TheVoid
from obj import Objects
from helper import _, playutils, api, window, settings, dialog
from helper import translate, playutils, api, window, settings, dialog
from dialogs import resume
#################################################################################################
@ -122,7 +122,7 @@ class Actions(object):
if settings('askCinema') == "true":
resp = dialog("yesno", heading="{jellyfin}", line1=_(33016))
resp = dialog("yesno", heading="{jellyfin}", line1=translate(33016))
if not resp:
enabled = False

View file

@ -236,7 +236,7 @@ import xbmcvfs
import requests
import resources.lib.image_cache_thread as image_cache_thread
from resources.lib.helper import _, window, settings, JSONRPC
from resources.lib.helper import translate, window, settings, JSONRPC
from resources.lib.database import Database
from __objs__ import QU
@ -274,16 +274,16 @@ class Artwork(object):
# and cache them locally. This takes diskspace!
if not dialog(type_="yesno",
heading="{jellyfin}",
line1=_(33042)):
line1=translate(33042)):
return
log.info("Doing Image Cache Sync")
pdialog = xbmcgui.DialogProgress()
pdialog.create(_(29999), _(33043))
pdialog.create(translate(29999), translate(33043))
# ask to rest all existing or not
if dialog(type_="yesno", heading="{jellyfin}", line1=_(33044)):
if dialog(type_="yesno", heading="{jellyfin}", line1=translate(33044)):
log.info("Resetting all cache data first")
self.delete_cache()
@ -292,14 +292,14 @@ class Artwork(object):
# Cache all entries in music DB
self._cache_all_music_entries(pdialog)
pdialog.update(100, "%s %s" % (_(33046), len(self.image_cache_threads)))
pdialog.update(100, "%s %s" % (translate(33046), len(self.image_cache_threads)))
log.info("Waiting for all threads to exit")
while len(self.image_cache_threads):
for thread in self.image_cache_threads:
if thread.is_finished:
self.image_cache_threads.remove(thread)
pdialog.update(100, "%s %s" % (_(33046), len(self.image_cache_threads)))
pdialog.update(100, "%s %s" % (translate(33046), len(self.image_cache_threads)))
log.info("Waiting for all threads to exit: %s", len(self.image_cache_threads))
xbmc.sleep(500)
@ -351,7 +351,7 @@ class Artwork(object):
percentage = int((float(count) / float(total))*100)
message = "%s of %s (%s)" % (count, total, len(self.image_cache_threads))
pdialog.update(percentage, "%s %s" % (_(33045), message))
pdialog.update(percentage, "%s %s" % (translate(33045), message))
self.cache_texture(url[0])
count += 1
@ -373,7 +373,7 @@ class Artwork(object):
percentage = int((float(count) / float(total))*100)
message = "%s of %s" % (count, total)
pdialog.update(percentage, "%s %s" % (_(33045), message))
pdialog.update(percentage, "%s %s" % (translate(33045), message))
self.cache_texture(url[0])
count += 1

View file

@ -9,7 +9,7 @@ import xbmc
import xbmcvfs
from objects.obj import Objects
from helper import _, api, window, settings, dialog, event, silent_catch, JSONRPC
from helper import translate, api, window, settings, dialog, event, silent_catch, JSONRPC
from jellyfin import Jellyfin
#################################################################################################
@ -436,7 +436,7 @@ class Player(xbmc.Player):
if delete:
LOG.info("Offer delete option")
if dialog("yesno", heading=_(30091), line1=_(33015), autoclose=120000):
if dialog("yesno", heading=translate(30091), line1=translate(33015), autoclose=120000):
item['Server'].jellyfin.delete_item(item['Id'])
window('jellyfin.external_check', clear=True)

View file

@ -4,7 +4,7 @@
import logging
from helper import _, settings, dialog, JSONRPC
from helper import translate, settings, dialog, JSONRPC
#################################################################################################
@ -40,7 +40,7 @@ class Setup(object):
if not self.get_web_server():
settings('enableTextureCache.bool', False)
dialog("ok", heading="{jellyfin}", line1=_(33103))
dialog("ok", heading="{jellyfin}", line1=translate(33103))
return
@ -84,22 +84,22 @@ class Setup(object):
''' Setup playback mode. If native mode selected, check network credentials.
'''
value = dialog("yesno",
heading=_('playback_mode'),
line1=_(33035),
nolabel=_('addon_mode'),
yeslabel=_('native_mode'))
heading=translate('playback_mode'),
line1=translate(33035),
nolabel=translate('addon_mode'),
yeslabel=translate('native_mode'))
settings('useDirectPaths', value="1" if value else "0")
if value:
dialog("ok", heading="{jellyfin}", line1=_(33145))
dialog("ok", heading="{jellyfin}", line1=translate(33145))
def _is_artwork_caching(self):
value = dialog("yesno", heading="{jellyfin}", line1=_(33117))
value = dialog("yesno", heading="{jellyfin}", line1=translate(33117))
settings('enableTextureCache.bool', value)
def _is_music(self):
value = dialog("yesno", heading="{jellyfin}", line1=_(33039))
value = dialog("yesno", heading="{jellyfin}", line1=translate(33039))
settings('enableMusic.bool', value=value)

View file

@ -12,7 +12,7 @@ import xbmc
import xbmcvfs
from database import Database, jellyfin_db, get_sync, save_sync
from helper import _, api, indent, write_xml, window, event
from helper import translate, api, indent, write_xml, window, event
from jellyfin import Jellyfin
#################################################################################################
@ -21,83 +21,83 @@ LOG = logging.getLogger("JELLYFIN." + __name__)
NODES = {
'tvshows': [
('all', None),
('recent', _(30170)),
('recentepisodes', _(30175)),
('inprogress', _(30171)),
('inprogressepisodes', _(30178)),
('nextepisodes', _(30179)),
('recent', translate(30170)),
('recentepisodes', translate(30175)),
('inprogress', translate(30171)),
('inprogressepisodes', translate(30178)),
('nextepisodes', translate(30179)),
('genres', 135),
('random', _(30229)),
('recommended', _(30230))
('random', translate(30229)),
('recommended', translate(30230))
],
'movies': [
('all', None),
('recent', _(30174)),
('inprogress', _(30177)),
('unwatched', _(30189)),
('recent', translate(30174)),
('inprogress', translate(30177)),
('unwatched', translate(30189)),
('sets', 20434),
('genres', 135),
('random', _(30229)),
('recommended', _(30230))
('random', translate(30229)),
('recommended', translate(30230))
],
'musicvideos': [
('all', None),
('recent', _(30256)),
('inprogress', _(30257)),
('unwatched', _(30258))
('recent', translate(30256)),
('inprogress', translate(30257)),
('unwatched', translate(30258))
]
}
DYNNODES = {
'tvshows': [
('all', None),
('RecentlyAdded', _(30170)),
('recentepisodes', _(30175)),
('InProgress', _(30171)),
('inprogressepisodes', _(30178)),
('nextepisodes', _(30179)),
('Genres', _(135)),
('Random', _(30229)),
('recommended', _(30230))
('RecentlyAdded', translate(30170)),
('recentepisodes', translate(30175)),
('InProgress', translate(30171)),
('inprogressepisodes', translate(30178)),
('nextepisodes', translate(30179)),
('Genres', translate(135)),
('Random', translate(30229)),
('recommended', translate(30230))
],
'movies': [
('all', None),
('RecentlyAdded', _(30174)),
('InProgress', _(30177)),
('Boxsets', _(20434)),
('Favorite', _(33168)),
('FirstLetter', _(33171)),
('Genres', _(135)),
('Random', _(30229)),
# ('Recommended', _(30230))
('RecentlyAdded', translate(30174)),
('InProgress', translate(30177)),
('Boxsets', translate(20434)),
('Favorite', translate(33168)),
('FirstLetter', translate(33171)),
('Genres', translate(135)),
('Random', translate(30229)),
# ('Recommended', translate(30230))
],
'musicvideos': [
('all', None),
('RecentlyAdded', _(30256)),
('InProgress', _(30257)),
('Unwatched', _(30258))
('RecentlyAdded', translate(30256)),
('InProgress', translate(30257)),
('Unwatched', translate(30258))
],
'homevideos': [
('all', None),
('RecentlyAdded', _(33167)),
('InProgress', _(33169)),
('Favorite', _(33168))
('RecentlyAdded', translate(33167)),
('InProgress', translate(33169)),
('Favorite', translate(33168))
],
'books': [
('all', None),
('RecentlyAdded', _(33167)),
('InProgress', _(33169)),
('Favorite', _(33168))
('RecentlyAdded', translate(33167)),
('InProgress', translate(33169)),
('Favorite', translate(33168))
],
'audiobooks': [
('all', None),
('RecentlyAdded', _(33167)),
('InProgress', _(33169)),
('Favorite', _(33168))
('RecentlyAdded', translate(33167)),
('InProgress', translate(33169)),
('Favorite', translate(33168))
],
'music': [
('all', None),
('RecentlyAdded', _(33167)),
('Favorite', _(33168))
('RecentlyAdded', translate(33167)),
('Favorite', translate(33168))
]
}
@ -256,9 +256,9 @@ class Views(object):
index += 1
for single in [{'Name': _('fav_movies'), 'Tag': "Favorite movies", 'Media': "movies"},
{'Name': _('fav_tvshows'), 'Tag': "Favorite tvshows", 'Media': "tvshows"},
{'Name': _('fav_episodes'), 'Tag': "Favorite episodes", 'Media': "episodes"}]:
for single in [{'Name': translate('fav_movies'), 'Tag': "Favorite movies", 'Media': "movies"},
{'Name': translate('fav_tvshows'), 'Tag': "Favorite tvshows", 'Media': "tvshows"},
{'Name': translate('fav_episodes'), 'Tag': "Favorite episodes", 'Media': "episodes"}]:
self.add_single_node(node_path, index, "favorites", single)
index += 1
@ -380,7 +380,7 @@ class Views(object):
etree.SubElement(xml, 'label')
label = xml.find('label')
label.text = view['Name'] if not mixed else "%s (%s)" % (view['Name'], _(view['Media']))
label.text = view['Name'] if not mixed else "%s (%s)" % (view['Name'], translate(view['Media']))
indent(xml)
write_xml(etree.tostring(xml, 'UTF-8'), file)
@ -712,7 +712,7 @@ class Views(object):
temp_view = dict(view)
temp_view['Media'] = media
temp_view['Name'] = "%s (%s)" % (view['Name'], _(media))
temp_view['Name'] = "%s (%s)" % (view['Name'], translate(media))
self.window_node(index, temp_view, *node)
self.window_wnode(windex, temp_view, *node)
else: # Add one to compensate for the duplicate.
@ -740,9 +740,9 @@ class Views(object):
index += 1
for single in [{'Name': _('fav_movies'), 'Tag': "Favorite movies", 'Media': "movies"},
{'Name': _('fav_tvshows'), 'Tag': "Favorite tvshows", 'Media': "tvshows"},
{'Name': _('fav_episodes'), 'Tag': "Favorite episodes", 'Media': "episodes"}]:
for single in [{'Name': translate('fav_movies'), 'Tag': "Favorite movies", 'Media': "movies"},
{'Name': translate('fav_tvshows'), 'Tag': "Favorite tvshows", 'Media': "tvshows"},
{'Name': translate('fav_episodes'), 'Tag': "Favorite episodes", 'Media': "episodes"}]:
self.window_single_node(index, "favorites", single)
index += 1
@ -772,7 +772,7 @@ class Views(object):
else:
window_path = "ActivateWindow(Videos,%s,return)" % path
node_label = _(node_label) if type(node_label) == int else node_label
node_label = translate(node_label) if type(node_label) == int else node_label
node_label = node_label or view['Name']
if node in ('all', 'music'):
@ -824,7 +824,7 @@ class Views(object):
else:
window_path = "ActivateWindow(Videos,%s,return)" % path
node_label = _(node_label) if type(node_label) == int else node_label
node_label = translate(node_label) if type(node_label) == int else node_label
node_label = node_label or view['Name']
if node == 'all':