Skip to content

Commit

Permalink
Ensure all constant strings in labels are localized
Browse files Browse the repository at this point in the history
  • Loading branch information
melmorabity committed Nov 26, 2020
1 parent c725bec commit 6ae6f27
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 10 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<icon>resources/icon.png</icon>
<fanart>resources/fanart.jpg</fanart>
</assets>
<news>v2.0.0 (2020-11-15)
<news>v2.0.0 (2020-11-27)
- Complete rewrite for france.tv mobile API switch
- Addon now follows the france.tv mobile application clickstream in terms of ergonomy

Expand Down
14 changes: 13 additions & 1 deletion resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: plugin.video.francetv\n"
"PO-Revision-Date: 2020-11-15 12:00+0200\n"
"PO-Revision-Date: 2020-11-25 12:00+0200\n"
"Last-Translator: melmorabity\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -33,6 +33,18 @@ msgctxt "#30005"
msgid "Search"
msgstr ""

msgctxt "#30101"
msgid "All TV shows"
msgstr ""

msgctxt "#30102"
msgid "All videos"
msgstr ""

msgctxt "#30103"
msgid "Next page"
msgstr ""

msgctxt "#30201"
msgid "Playback failed"
msgstr ""
14 changes: 13 additions & 1 deletion resources/language/resource.language.fr_fr/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: plugin.video.francetv\n"
"PO-Revision-Date: 2020-11-15 12:00+0200\n"
"PO-Revision-Date: 2020-11-25 12:00+0200\n"
"Last-Translator: melmorabity\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -33,6 +33,18 @@ msgctxt "#30005"
msgid "Search"
msgstr "Recherche"

msgctxt "#30101"
msgid "All TV shows"
msgstr "Tous les programmes"

msgctxt "#30102"
msgid "All videos"
msgstr "Toutes les vidéos"

msgctxt "#30103"
msgid "Next page"
msgstr "Page suivante"

msgctxt "#30201"
msgid "Playback failed"
msgstr "Échec de lecture"
14 changes: 13 additions & 1 deletion resources/lib/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from __future__ import unicode_literals
import logging
import os
import re

try:
from typing import Dict
Expand Down Expand Up @@ -80,13 +81,24 @@ def _params_to_dict(params):
# Parameter string starts with a '?'
return dict(parse_qsl(params[1:])) if params else {}

def _localize(self, label):
# type: (Text) -> Text

return re.sub(
r"\$LOCALIZE\[(\d+)\]",
lambda m: self._ADDON.getLocalizedString(int(m.group(1))),
label,
)

def _add_listitem(self, parsed_item):
# type: (ParsedItem) -> None

is_folder = parsed_item.url.get("mode") != "watch"

_LOGGER.debug("Add ListItem %s", parsed_item)
listitem = ListItem(label=parsed_item.label, offscreen=True)
listitem = ListItem(
label=self._localize(parsed_item.label), offscreen=True
)
listitem.setInfo("video", parsed_item.info)

# Set fallback fanart
Expand Down
12 changes: 6 additions & 6 deletions resources/lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,27 +465,27 @@ def get_collection(self, path, level=None):
# Add "all TV shows"/"all programs" item
if parent_item_type != "program":
yield ParsedItem(
"Tous les programmes",
"$LOCALIZE[30101]",
{
"mode": "collection",
"path": "apps/regions/{}/programs".format(
collection_id
),
},
{"plot": "Tous les programmes"},
{"plot": ""},
{"icon": _ALL_TV_SHOWS_ICON},
{"SpecialSort": "bottom"},
)

yield ParsedItem(
"Toutes les vidéos",
"$LOCALIZE[30102]",
{
"mode": "collection",
"path": "generic/taxonomy/{}/contents".format(
collection_id
),
},
{"plot": "Toutes les vidéos"},
{"plot": ""},
{"icon": _ALL_VIDEOS_ICON},
{"SpecialSort": "bottom"},
)
Expand All @@ -497,7 +497,7 @@ def get_collection(self, path, level=None):
and cursor.get("last")
):
# Add "next page" item
label = "Page suivante ({}/{})".format(
label = "$LOCALIZE[30103] ({}/{})".format(
cursor["next"] + 1, cursor["last"] + 1
)
yield ParsedItem(
Expand All @@ -506,7 +506,7 @@ def get_collection(self, path, level=None):
"mode": "collection",
"path": update_url_params(path, page=cursor["next"]),
},
{"plot": label},
{"plot": ""},
{"icon": _NEXT_PAGE_ICON},
{"SpecialSort": "bottom"},
)

0 comments on commit 6ae6f27

Please sign in to comment.