From b4ade1d672a92c5211f9478a45c8550f22f38a85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Dav=C3=B3?= Date: Fri, 23 Dec 2016 18:42:51 +0100 Subject: [PATCH] Language Now with Spanish support --- resources/language/English/strings.po | 75 +++++++++++++++++++++++++++ resources/language/Spanish/strings.po | 75 +++++++++++++++++++++++++++ resources/lib/interface.py | 8 +-- resources/lib/simklapi.py | 4 +- resources/settings.xml | 12 +++-- service.py | 6 ++- 6 files changed, 169 insertions(+), 11 deletions(-) create mode 100644 resources/language/English/strings.po create mode 100644 resources/language/Spanish/strings.po diff --git a/resources/language/English/strings.po b/resources/language/English/strings.po new file mode 100644 index 0000000..edd0aaf --- /dev/null +++ b/resources/language/English/strings.po @@ -0,0 +1,75 @@ +# Kodi Media Center language file +# Addon Name: Simkl TV Tracker +# Addon id: script.services.simkl + +msgid "" +msgstr "" +"Project-Id-Version: Kodi Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: David Davó\n" +"Language-Team: English\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: en\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#Settings + +msgctxt "#32001" +msgid "Please click to Log In" +msgstr "" + +msgctxt "#32002" +msgid "Other options" +msgstr "" + +msgctxt "#32003" +msgid "Sync library" +msgstr "" + +msgctxt "#32006" +msgid "Scrobble at percentage" +msgstr "" + +msgctxt "#32007" +msgid "Checkin percentage" +msgstr "" + +msgctxt "#32008" +msgid "Show bubble when scrobbled" +msgstr "" + +#Up to 32020 to settings. 32021-2024 to login dialog + +msgctxt "#32021" +msgid "Simkl login" +msgstr "" + +msgctxt "#32022" +msgid "Enter to the following URL: {}" +msgstr "" + +msgctxt "#32023" +msgcid "Remaining time: {}/{}" +msgstr "" + +# Blahblahblah + +msgctxt "#32025" +msgid "Hello again, {}" +msgstr "" + +msgctxt "#32026" +msgid "Please Log In in addon settings" +msgstr "" + +msgctxt "#32027" +msgid "You don't have internet" +msgstr "" + +#msgctxt "#" +#msgid "" +#msgstr "" \ No newline at end of file diff --git a/resources/language/Spanish/strings.po b/resources/language/Spanish/strings.po new file mode 100644 index 0000000..b242cb3 --- /dev/null +++ b/resources/language/Spanish/strings.po @@ -0,0 +1,75 @@ +# Kodi Media Center language file +# Addon Name: Simkl TV Tracker +# Addon id: script.services.simkl + +msgid "" +msgstr "" +"Project-Id-Version: Kodi Addons\n" +"Report-Msgid-Bugs-To: alanwww1@xbmc.org\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: David Davó\n" +"Language-Team: Spanish\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: es\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#Settings + +msgctxt "#32001" +msgid "Please click to Log In" +msgstr "Por favor haz click para iniciar sesión" + +msgctxt "#32002" +msgid "Other options" +msgstr "Otras opciones" + +msgctxt "#32003" +msgid "Sync library" +msgstr "Sincronizar librerías" + +msgctxt "#32006" +msgid "Scrobble at percentage" +msgstr "Scrobble al llegar a..." + +msgctxt "#32007" +msgid "Checkin percentage" +msgstr "Checkin al llegar a..." + +msgctxt "#32008" +msgid "Show bubble when scrobbled" +msgstr "Mostrar notificación al scrobble" + +#Up to 32020 to settings + +msgctxt "#32021" +msgid "Simkl login" +msgstr "Inicio de sesión en Simkl" + +msgctxt "#32022" +msgid "Enter to the following URL: {}" +msgstr "Entra a la siguiente URL: {}" + +msgctxt "#32023" +msgcid "Remaining time: {}/{}" +msgstr "Tiempo restante: {}/{}" + +# Blahblahblah + +msgctxt "#32025" +msgid "Hello again, {}" +msgstr "Hola de nuevo, {}" + +msgctxt "#32026" +msgid "Please Log In in addon settings" +msgstr "Por favor inicia sesión en la configuración del addon" + +msgctxt "#32027" +msgid "You don't have internet" +msgstr "No tienes conexión a internet" + +#msgctxt "#" +#msgid "" +#msgstr "" \ No newline at end of file diff --git a/resources/lib/interface.py b/resources/lib/interface.py index a249fee..f22a383 100644 --- a/resources/lib/interface.py +++ b/resources/lib/interface.py @@ -6,6 +6,8 @@ __addon__ = xbmcaddon.Addon("script.service.simkl") __icon__ = __addon__.getAddonInfo("icon") +def getstr(id): return __addon__.getLocalizedString(id) + xbmc.log("Simkl: Icon: "+str(__icon__)) not_dialog = xbmcgui.Dialog() @@ -19,13 +21,13 @@ def __init__(self, url, pin, check_login, log, exp=900, inter=5, api=None): #TODO: If user is loged in, show a confirmation dialog API = api self.dialog = xbmcgui.DialogProgress() - self.dialog.create("Simkl login", - "Enter to the following URL: {}".format(url), "PIN: {}".format(pin)) + self.dialog.create(getstr(32021), + getstr(32022).format(url), "PIN: {}".format(pin)) waiting = True cnt = 0 while waiting: pct = min(max(1, int( round( cnt*100 / exp, 0))), 99) - self.dialog.update(pct, line3="Remaining time: {}/{}".format( + self.dialog.update(pct, line3=getstr(32023).format( str(cnt).zfill(3), exp)) if cnt % (inter+1) == 0 and cnt>1: diff --git a/resources/lib/simklapi.py b/resources/lib/simklapi.py index 0a92fa8..38e9f72 100644 --- a/resources/lib/simklapi.py +++ b/resources/lib/simklapi.py @@ -13,6 +13,8 @@ import interface import httplib +def getstr(id): return interface.getstr(id) + REDIRECT_URI = "http://simkl.com" USERFILE = xbmc.translatePath("special://profile/simkl_key") if not os.path.exists(USERFILE): @@ -46,7 +48,7 @@ def __init__(self): api.login() except Exception: xbmc.log("Simkl: {}".format("No INTERNET")) - interface.notify("You don't have internet") + interface.notify(getstr(32027)) self.internet = False def login(self): diff --git a/resources/settings.xml b/resources/settings.xml index ae3c680..f1c38ab 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -1,15 +1,17 @@ - + - - + + - - + + + diff --git a/service.py b/service.py index 72cae3b..c947e7a 100644 --- a/service.py +++ b/service.py @@ -12,7 +12,9 @@ from resources.lib import simklapi as API simkl_addon = xbmcaddon.Addon() +interface.__addon__ = simkl_addon autoscrobble = simkl_addon.getSetting("autoscrobble") +def getstr(id): return simkl_addon.getLocalizedString(id) if __name__ == "__main__": xbmc.log("Simkl dir: " + str(xbmc.translatePath("special://home"))) @@ -26,9 +28,9 @@ #Remember: if getTime() is more than x% scrobble file if not API.api.is_user_logged(): - interface.notify("Please Log In in addon settings") + interface.notify(getstr(32026)) else: - interface.notify("Hello again {}".format(API.api.USERSETTINGS["user"]["name"])) + interface.notify(getstr(32025).format(API.api.USERSETTINGS["user"]["name"])) while not monitor.abortRequested(): if monitor.waitForAbort(60):