diff --git a/data/deps.json b/data/deps.json index 86ae8e6..49a7cc1 100644 --- a/data/deps.json +++ b/data/deps.json @@ -1,6 +1,6 @@ { "lxml": "5.3.0", - "rapidfuzz": "3.9.7", + "rapidfuzz": "3.10.0", "spacy": "3.7.6", "spacy_cpu_model": "3.7.0", "en_spacy_cpu_model": "3.7.1", diff --git a/data/languages.json b/data/languages.json index b93199f..16beba1 100644 --- a/data/languages.json +++ b/data/languages.json @@ -80,6 +80,11 @@ "name": "Hebrew", "spacy": "" }, + "hi": { + "gloss_source": "", + "name": "Hindi", + "spacy": "" + }, "hr": { "639-2": "hrv", "gloss_source": "dbnary", @@ -90,6 +95,11 @@ "name": "Serbo-Croatian", "spacy": "hr_core_news_" }, + "id": { + "gloss_source": "", + "name": "Indonesian", + "spacy": "" + }, "it": { "639-2": "ita", "gloss_source": "dbnary", @@ -132,6 +142,11 @@ "name": "Macedonian", "spacy": "mk_core_news_" }, + "ms": { + "gloss_source": "", + "name": "Malay", + "spacy": "" + }, "nl": { "639-2": "nld", "gloss_source": "dbnary", diff --git a/docs/index.rst b/docs/index.rst index de7bb38..3abb244 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -42,36 +42,39 @@ Supported languages Supported Word Wise definition languages are listed in the plugin's customize window. -============= ===== -Book language X-Ray -============= ===== -Bokmål ✅ -Català ✅ -Dansk ✅ -Deutsch ✅ -English ✅ -Español ✅ -Français ✅ -Hrvatski ✅ -Italiano ✅ -Lietuvių ✅ -Nederlands ✅ -Polski ✅ -Português ✅ -Română ✅ -Slovenščina ✅ -Suomi ✅ -Svenska ✅ -čeština ❌ -Ελληνικά ✅ -Македонски ✅ -Русский ✅ -Українська ✅ -עִבְֿרִית‎ ❌ -中文 ✅ -日本語 ✅ -한국어 ✅ -============= ===== +================ ===== +Book language X-Ray +================ ===== +Bahasa Indonesia ❌ +Bahasa Melayu ❌ +Bokmål ✅ +Català ✅ +Dansk ✅ +Deutsch ✅ +English ✅ +Español ✅ +Français ✅ +Hrvatski ✅ +Italiano ✅ +Lietuvių ✅ +Nederlands ✅ +Polski ✅ +Português ✅ +Română ✅ +Slovenščina ✅ +Suomi ✅ +Svenska ✅ +čeština ❌ +Ελληνικά ✅ +Македонски ✅ +Русский ✅ +Українська ✅ +עִבְֿרִית‎ ❌ +हिन्दी ❌ +中文 ✅ +日本語 ✅ +한국어 ✅ +================ ===== Community --------- diff --git a/metadata.py b/metadata.py index 4ef6482..6e2d655 100644 --- a/metadata.py +++ b/metadata.py @@ -33,17 +33,18 @@ def is_ww_supported(book_lang: str, gloss_lang: str) -> bool: def check_metadata(gui: Any, book_id: int, custom_x_ray: bool) -> MetaDataResult | None: + from calibre.utils.localization import lang_as_iso639_1 + from .config import prefs from .error_dialogs import unsupported_format_dialog, unsupported_language_dialog from .utils import get_plugin_path, load_languages_data db = gui.current_db.new_api lang_dict = load_languages_data(get_plugin_path(), False) - supported_languages = {v["639-2"]: k for k, v in lang_dict.items()} mi = db.get_metadata(book_id, get_cover=True) # https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes - calibre_book_lang = mi.get("language") - if calibre_book_lang not in supported_languages: + book_lang = lang_as_iso639_1(mi.get("language")) + if book_lang not in lang_dict: unsupported_language_dialog(mi.get("title")) return None @@ -63,7 +64,6 @@ def check_metadata(gui: Any, book_id: int, custom_x_ray: bool) -> MetaDataResult if not prefs["use_all_formats"]: supported_fmts = [supported_fmts[0]] - book_lang = supported_languages[calibre_book_lang] support_ww_list = [] for fmt in supported_fmts: gloss_lang = prefs["gloss_lang"] @@ -81,11 +81,11 @@ def check_metadata(gui: Any, book_id: int, custom_x_ray: bool) -> MetaDataResult def cli_check_metadata(book_path_str: str, log: Any) -> MetaDataResult | None: + from calibre.utils.localization import lang_as_iso639_1 + from .config import prefs from .utils import get_plugin_path, load_languages_data - lang_dict = load_languages_data(get_plugin_path(), False) - supported_languages = {v["639-2"]: k for k, v in lang_dict.items()} book_path = Path(book_path_str) book_fmt = book_path.suffix.upper()[1:] mi = None @@ -112,14 +112,14 @@ def cli_check_metadata(book_path_str: str, log: Any) -> MetaDataResult | None: mi = get_metadata(f) if mi is not None: - calibre_book_lang = mi.get("language") - if calibre_book_lang not in supported_languages: + lang_dict = load_languages_data(get_plugin_path(), False) + book_lang = lang_as_iso639_1(mi.get("language")) + if book_lang not in lang_dict: log.prints( log.WARN, f"The language of the book {mi.get('title')} is not supported.", ) return None - book_lang = supported_languages[calibre_book_lang] gloss_lang = prefs["gloss_lang"] return MetaDataResult( book_fmts=[book_fmt], diff --git a/utils.py b/utils.py index 1e971ce..a2855a3 100644 --- a/utils.py +++ b/utils.py @@ -9,7 +9,7 @@ from typing import Any, TypedDict CJK_LANGS = ["zh", "ja", "ko"] -PROFICIENCY_VERSION = "0.5.21" +PROFICIENCY_VERSION = "0.5.22" PROFICIENCY_RELEASE_URL = ( f"https://github.com/xxyzz/Proficiency/releases/download/v{PROFICIENCY_VERSION}" )