Skip to content

Commit

Permalink
Localise job notification strings
Browse files Browse the repository at this point in the history
  • Loading branch information
ping committed Jul 6, 2023
1 parent ee16f52 commit 25b9463
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 73 deletions.
4 changes: 3 additions & 1 deletion calibre-plugin/borrow_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from .libby import LibbyClient
from .model import get_loan_title

load_translations()


class LibbyBorrowHold:
def __call__(
Expand All @@ -16,7 +18,7 @@ def __call__(
notifications=None,
):
logger = log
notifications.put((0.5, "Borrowing"))
notifications.put((0.5, _("Borrowing")))
libby_client.borrow_hold(hold, card)
logger.info(
"Borrowed %s successfully from %s."
Expand Down
4 changes: 3 additions & 1 deletion calibre-plugin/ebook_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from .libby import LibbyClient


load_translations()

# Ref: https://github.com/kovidgoyal/calibre/blob/58c609fa7db3a8df59981c3bf73823fa1862c392/src/calibre/gui2/ebook_download.py#L77-L122
class CustomEbookDownload(EbookDownload):
def __call__(
Expand Down Expand Up @@ -67,7 +69,7 @@ def _custom_download(
notifications=None,
) -> str:
temp_path = os.path.join(PersistentTemporaryDirectory(), filename)
notifications.put((0.5, "Downloading"))
notifications.put((0.5, _("Downloading")))
res_content = libby_client.fulfill_loan_file(
loan["id"], loan["cardId"], format_id
)
Expand Down
4 changes: 3 additions & 1 deletion calibre-plugin/hold_cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from .libby import LibbyClient
from .model import get_loan_title

load_translations()


class LibbyHoldCancel:
def __call__(
Expand All @@ -15,6 +17,6 @@ def __call__(
notifications=None,
):
logger = log
notifications.put((0.5, "Cancelling"))
notifications.put((0.5, _("Cancelling")))
libby_client.cancel_hold(hold)
logger.info("Cancelled hold for %s successfully." % get_loan_title(hold))
4 changes: 3 additions & 1 deletion calibre-plugin/loan_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from .libby import LibbyClient
from .model import get_loan_title

load_translations()


class LibbyLoanReturn:
def __call__(
Expand All @@ -15,6 +17,6 @@ def __call__(
notifications=None,
):
logger = log
notifications.put((0.5, "Returning"))
notifications.put((0.5, _("Returning")))
libby_client.return_loan(loan)
logger.info("Returned %s successfully." % get_loan_title(loan))
20 changes: 11 additions & 9 deletions calibre-plugin/magazine_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
</html>
"""

load_translations()


def _sort_toc(toc: Dict) -> List:
"""
Expand Down Expand Up @@ -404,17 +406,17 @@ def _custom_download(
notifications.put(
(
(1 / meta_tasks) * meta_progress_fraction,
"Getting loan details",
_("Getting loan details"),
)
)
_, openbook, rosters = libby_client.process_ebook(loan)
__, openbook, rosters = libby_client.process_ebook(loan)
cover_url = get_best_cover_url(loan)
cover_path = book_folder.joinpath("cover.jpg")
try:
notifications.put(
(
(2 / meta_tasks) * meta_progress_fraction,
"Downloading cover",
_("Downloading cover"),
)
)
with cover_path.open("w+b") as cover_f:
Expand Down Expand Up @@ -443,7 +445,7 @@ def _custom_download(
notifications.put(
(
(3 / meta_tasks) * meta_progress_fraction,
"Getting book details",
_("Getting book details"),
)
)
media_info = od_client.media(loan["id"])
Expand Down Expand Up @@ -582,7 +584,7 @@ def _custom_download(
font_families = list(
set(patch_magazine_css_font_re.findall(css_content))
)
for font_family, _ in font_families:
for font_family, __ in font_families:
new_font_css = font_family[:-1]
if "Serif" in font_family:
new_font_css += ',Charter,"Bitstream Charter","Sitka Text",Cambria,serif'
Expand Down Expand Up @@ -671,7 +673,7 @@ def _custom_download(
(
(i / total_downloads) * download_progress_fraction
+ meta_progress_fraction,
"Downloading",
_("Downloading"),
)
)

Expand Down Expand Up @@ -866,7 +868,7 @@ def _custom_download(
if cover_img_manifest_id:
metadata = package.find("metadata")
if metadata:
_ = ET.SubElement(
__ = ET.SubElement(
metadata,
"meta",
attrib={"name": "cover", "content": cover_img_manifest_id},
Expand Down Expand Up @@ -906,7 +908,7 @@ def _custom_download(
if openbook.get("nav", {}).get("landmarks"):
guide = ET.SubElement(package, "guide")
for landmark in openbook["nav"]["landmarks"]:
_ = ET.SubElement(
__ = ET.SubElement(
guide,
"reference",
attrib={
Expand All @@ -928,7 +930,7 @@ def _custom_download(
},
)
root_files = ET.SubElement(container, "rootfiles")
_ = ET.SubElement(
__ = ET.SubElement(
root_files,
"rootfile",
attrib={
Expand Down
52 changes: 40 additions & 12 deletions calibre-plugin/translations/default.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: libby-calibre-plugin 0.1.3\n"
"Report-Msgid-Bugs-To: https://github.com/ping/libby-calibre-plugin/\n"
"POT-Creation-Date: 2023-07-06 20:09+0800\n"
"POT-Creation-Date: 2023-07-06 22:40+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand All @@ -22,10 +22,14 @@ msgstr ""
msgid "Import loans from your OverDrive Libby account"
msgstr ""

#: calibre-plugin/action.py:44
#: calibre-plugin/action.py:43
msgid "Run the OverDrive Libby client UI"
msgstr ""

#: calibre-plugin/borrow_book.py:21
msgid "Borrowing"
msgstr ""

#: calibre-plugin/config.py:38 calibre-plugin/config.py:253
msgid "Libby Setup Code"
msgstr ""
Expand Down Expand Up @@ -91,6 +95,30 @@ msgstr ""
msgid "Invalid setup code format: {code}"
msgstr ""

#: calibre-plugin/ebook_download.py:72 calibre-plugin/magazine_download.py:676
msgid "Downloading"
msgstr ""

#: calibre-plugin/hold_cancel.py:20
msgid "Cancelling"
msgstr ""

#: calibre-plugin/loan_return.py:20
msgid "Returning"
msgstr ""

#: calibre-plugin/magazine_download.py:409
msgid "Getting loan details"
msgstr ""

#: calibre-plugin/magazine_download.py:419
msgid "Downloading cover"
msgstr ""

#: calibre-plugin/magazine_download.py:448
msgid "Getting book details"
msgstr ""

#: calibre-plugin/model.py:42
msgid "ebook"
msgstr ""
Expand All @@ -99,43 +127,43 @@ msgstr ""
msgid "magazine"
msgstr ""

#: calibre-plugin/model.py:104 calibre-plugin/model.py:203
#: calibre-plugin/model.py:108 calibre-plugin/model.py:211
msgid "Title"
msgstr ""

#: calibre-plugin/model.py:105 calibre-plugin/model.py:204
#: calibre-plugin/model.py:109 calibre-plugin/model.py:212
msgid "Author"
msgstr ""

#: calibre-plugin/model.py:106
#: calibre-plugin/model.py:110
msgid "Checkout Date"
msgstr ""

#: calibre-plugin/model.py:107 calibre-plugin/model.py:207
#: calibre-plugin/model.py:111 calibre-plugin/model.py:215
msgid "Type"
msgstr ""

#: calibre-plugin/model.py:108
#: calibre-plugin/model.py:112
msgid "Format"
msgstr ""

#: calibre-plugin/model.py:205
#: calibre-plugin/model.py:213
msgid "Hold Date"
msgstr ""

#: calibre-plugin/model.py:206
#: calibre-plugin/model.py:214
msgid "Library"
msgstr ""

#: calibre-plugin/model.py:208
#: calibre-plugin/model.py:216
msgid "Available"
msgstr ""

#: calibre-plugin/model.py:294
#: calibre-plugin/model.py:302
msgid "Yes"
msgstr ""

#: calibre-plugin/model.py:294
#: calibre-plugin/model.py:302
msgid "No"
msgstr ""

Expand Down
52 changes: 40 additions & 12 deletions calibre-plugin/translations/ja.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: libby-calibre-plugin 0.1.3\n"
"Report-Msgid-Bugs-To: https://github.com/ping/libby-calibre-plugin/\n"
"POT-Creation-Date: 2023-07-06 20:09+0800\n"
"POT-Creation-Date: 2023-07-06 22:40+0800\n"
"PO-Revision-Date: 2023-07-04 07:26+0800\n"
"Last-Translator: \n"
"Language-Team: \n"
Expand All @@ -22,10 +22,14 @@ msgstr ""
msgid "Import loans from your OverDrive Libby account"
msgstr "OverDrive Libbyアカウントからローンをインポート"

#: calibre-plugin/action.py:44
#: calibre-plugin/action.py:43
msgid "Run the OverDrive Libby client UI"
msgstr "OverDrive LibbyクライアントUIを実行します"

#: calibre-plugin/borrow_book.py:21
msgid "Borrowing"
msgstr ""

#: calibre-plugin/config.py:38 calibre-plugin/config.py:253
msgid "Libby Setup Code"
msgstr "Libby セットアップコード"
Expand Down Expand Up @@ -91,6 +95,30 @@ msgstr "Libbyが構成されていません。"
msgid "Invalid setup code format: {code}"
msgstr ""

#: calibre-plugin/ebook_download.py:72 calibre-plugin/magazine_download.py:676
msgid "Downloading"
msgstr ""

#: calibre-plugin/hold_cancel.py:20
msgid "Cancelling"
msgstr ""

#: calibre-plugin/loan_return.py:20
msgid "Returning"
msgstr ""

#: calibre-plugin/magazine_download.py:409
msgid "Getting loan details"
msgstr ""

#: calibre-plugin/magazine_download.py:419
msgid "Downloading cover"
msgstr ""

#: calibre-plugin/magazine_download.py:448
msgid "Getting book details"
msgstr ""

#: calibre-plugin/model.py:42
msgid "ebook"
msgstr "電子書籍"
Expand All @@ -99,43 +127,43 @@ msgstr "電子書籍"
msgid "magazine"
msgstr "雑誌"

#: calibre-plugin/model.py:104 calibre-plugin/model.py:203
#: calibre-plugin/model.py:108 calibre-plugin/model.py:211
msgid "Title"
msgstr "タイトル"

#: calibre-plugin/model.py:105 calibre-plugin/model.py:204
#: calibre-plugin/model.py:109 calibre-plugin/model.py:212
msgid "Author"
msgstr "著者"

#: calibre-plugin/model.py:106
#: calibre-plugin/model.py:110
msgid "Checkout Date"
msgstr "借入日"

#: calibre-plugin/model.py:107 calibre-plugin/model.py:207
#: calibre-plugin/model.py:111 calibre-plugin/model.py:215
msgid "Type"
msgstr "タイプ"

#: calibre-plugin/model.py:108
#: calibre-plugin/model.py:112
msgid "Format"
msgstr "形式"

#: calibre-plugin/model.py:205
#: calibre-plugin/model.py:213
msgid "Hold Date"
msgstr ""

#: calibre-plugin/model.py:206
#: calibre-plugin/model.py:214
msgid "Library"
msgstr "図書館"

#: calibre-plugin/model.py:208
#: calibre-plugin/model.py:216
msgid "Available"
msgstr "貸出可能"

#: calibre-plugin/model.py:294
#: calibre-plugin/model.py:302
msgid "Yes"
msgstr "はい"

#: calibre-plugin/model.py:294
#: calibre-plugin/model.py:302
msgid "No"
msgstr "いいえ"

Expand Down

0 comments on commit 25b9463

Please sign in to comment.