diff --git a/README.md b/README.md index 13eb026df..f1c20fa12 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,14 @@ Finally decent dictionaries based on [Wiktionary](https://www.wiktionary.org/) f ### Requirements +#### Kobo + Kobo firmware >= 4.24. For older firmwares, you can find outdated dictionaries [here](https://github.com/BoboTiG/ebook-reader-dict/actions/runs/350446645). ## Updating Dictionaries All dictionaries are automatically re-generated **every day** at midnight. The process uses the latest Wiktionary dump available at that time. -The `dicthml-LOCALE.zip` files are updated in place so that the download link never changes. +Files are updated in place so that download links never changes. - You should open an [issue](https://github.com/BoboTiG/ebook-reader-dict/issues) if: - you do not find a word; diff --git a/wikidict/constants.py b/wikidict/constants.py index bf1b70031..cca1dca24 100644 --- a/wikidict/constants.py +++ b/wikidict/constants.py @@ -11,7 +11,9 @@ REPOS = "BoboTiG/ebook-reader-dict" GH_REPOS = f"https://github.com/{REPOS}" RELEASE_URL = f"https://api.github.com/repos/{REPOS}/releases/tags/{{0}}" -DOWNLOAD_URL = f"{GH_REPOS}/releases/download/{{0}}/dicthtml-{{0}}.zip" +DOWNLOAD_URL_DICTFILE = f"{GH_REPOS}/releases/download/{{0}}/dict-{{0}}.df" +DOWNLOAD_URL_KOBO = f"{GH_REPOS}/releases/download/{{0}}/dicthtml-{{0}}.zip" +DOWNLOAD_URL_STARDICT = f"{GH_REPOS}/releases/download/{{0}}/dict-{{0}}.zip" # HTML formatting for each word # TODO: move that into the dict specific class diff --git a/wikidict/lang/ca/__init__.py b/wikidict/lang/ca/__init__.py index 15945b451..eaeb5ca70 100644 --- a/wikidict/lang/ca/__init__.py +++ b/wikidict/lang/ca/__init__.py @@ -174,10 +174,11 @@ def parse_other_parameters() -> str: Les paraules compten: {words_count} Abocador Viccionari: {dump_date} -Instal·lació: +Fitxers disponibles: -1. Copieu el fitxer [dicthtml-{locale}.zip :floppy_disk:]({url}) a la carpeta `.kobo/custom-dict/` del lector. -2. **Reinicieu** el lector. +- [Kobo]({url_kobo}) (dicthtml-{locale}.zip) +- [StarDict]({url_stardict}) (dict-{locale}.zip) +- [DictFile]({url_dictfile}) (dict-{locale}.df) Actualitzat el {creation_date} """ # noqa diff --git a/wikidict/lang/en/__init__.py b/wikidict/lang/en/__init__.py index 8a59ce982..11e5f4e40 100644 --- a/wikidict/lang/en/__init__.py +++ b/wikidict/lang/en/__init__.py @@ -253,10 +253,11 @@ def last_template_handler( Words count: {words_count} Wiktionary dump: {dump_date} -Installation: +Available files: -1. Copy the [dicthtml-{locale}.zip :floppy_disk:]({url}) file into the `.kobo/custom-dict/` folder of the reader. -2. **Restart** the reader. +- [Kobo]({url_kobo}) (dicthtml-{locale}.zip) +- [StarDict]({url_stardict}) (dict-{locale}.zip) +- [DictFile]({url_dictfile}) (dict-{locale}.df) Updated on {creation_date} """ # noqa diff --git a/wikidict/lang/es/__init__.py b/wikidict/lang/es/__init__.py index f7401c7b5..449392927 100644 --- a/wikidict/lang/es/__init__.py +++ b/wikidict/lang/es/__init__.py @@ -280,10 +280,11 @@ def last_template_handler( Número de palabras: {words_count} exportación Wikcionario: {dump_date} -Instalacións: +Archivos disponibles: -1. Copia el archivo [dicthtml-{locale}.zip :floppy_disk:]({url}) en el directorio `.kobo/custom-dict/` del lector. -2. **Reinicie** la luz de lectura. +- [Kobo]({url_kobo}) (dicthtml-{locale}.zip) +- [StarDict]({url_stardict}) (dict-{locale}.zip) +- [DictFile]({url_dictfile}) (dict-{locale}.df) Actualizado el {creation_date} """ # noqa diff --git a/wikidict/lang/fr/__init__.py b/wikidict/lang/fr/__init__.py index 7d579a42e..a620cfe71 100644 --- a/wikidict/lang/fr/__init__.py +++ b/wikidict/lang/fr/__init__.py @@ -756,10 +756,11 @@ def last_template_handler( Nombre de mots : {words_count} Export Wiktionnaire : {dump_date} -Installation : +Fichiers disponibles : -1. Copier le fichier [dicthtml-{locale}.zip :floppy_disk:]({url}) dans le dossier `.kobo/custom-dict/` de la liseuse. -2. **Redémarrer** la liseuse. +- [Kobo]({url_kobo}) (dicthtml-{locale}.zip) +- [StarDict]({url_stardict}) (dict-{locale}.zip) +- [DictFile]({url_dictfile}) (dict-{locale}.df) Mis à jour le {creation_date} """ # noqa diff --git a/wikidict/lang/pt/__init__.py b/wikidict/lang/pt/__init__.py index 84ca7586a..e649fa1da 100644 --- a/wikidict/lang/pt/__init__.py +++ b/wikidict/lang/pt/__init__.py @@ -189,10 +189,11 @@ def last_template_handler( As palavras contam: {words_count} Exportação Wikcionário: {dump_date} -Instalação: +Arquivos disponíveis: -1. Copiar o ficheiro [dicthtml-{locale}.zip :floppy_disk:]({url}) para a pasta `.kobo/custom-dict/` do leitor. -2. **Reiniciar** o leitor. +- [Kobo]({url_kobo}) (dicthtml-{locale}.zip) +- [StarDict]({url_stardict}) (dict-{locale}.zip) +- [DictFile]({url_dictfile}) (dict-{locale}.df) Actualizado em {creation_date} """ # noqa diff --git a/wikidict/lang/sv.py b/wikidict/lang/sv.py index 0546d88a1..cc8f7d36e 100644 --- a/wikidict/lang/sv.py +++ b/wikidict/lang/sv.py @@ -49,10 +49,11 @@ Ord räknas: {words_count} Dumpa Wiktionary: {dump_date} -Installation: +Tillgängliga filer: -1. Kopiera filen [dicthtml-{locale}.zip :floppy_disk:]({url}) till läsaren `.kobo/custom-dict/` mappen på läsaren. -2. **Starta** om läsaren. +- [Kobo]({url_kobo}) (dicthtml-{locale}.zip) +- [StarDict]({url_stardict}) (dict-{locale}.zip) +- [DictFile]({url_dictfile}) (dict-{locale}.df) Uppdaterad på {creation_date} """ # noqa diff --git a/wikidict/utils.py b/wikidict/utils.py index 01565fd9c..8ae2f5153 100644 --- a/wikidict/utils.py +++ b/wikidict/utils.py @@ -10,7 +10,12 @@ from cachetools.keys import hashkey import regex -from .constants import DOWNLOAD_URL, IMG_CSS +from .constants import ( + DOWNLOAD_URL_DICTFILE, + DOWNLOAD_URL_KOBO, + DOWNLOAD_URL_STARDICT, + IMG_CSS, +) from .lang import ( last_template_handler, pattern_file, @@ -66,26 +71,23 @@ def format_description(locale: str, output_dir: Path) -> str: """Generate the release description.""" # Get the words count - count = (output_dir / "words.count").read_text().strip() + words_count = (output_dir / "words.count").read_text().strip() # Format the words count thousands_sep = thousands_separator[locale] - count = f"{int(count):,}".replace(",", thousands_sep) + words_count = f"{int(words_count):,}".replace(",", thousands_sep) # Format the snapshot's date - snapshot = (output_dir / "words.snapshot").read_text().strip() - snapshot = f"{snapshot[:4]}-{snapshot[4:6]}-{snapshot[6:8]}" - - # The download link - url = DOWNLOAD_URL.format(locale) - - return release_description[locale].format( - creation_date=NOW.isoformat(), - dump_date=snapshot, - locale=locale, - url=url, - words_count=count, - ) + dump_date = (output_dir / "words.snapshot").read_text().strip() + dump_date = f"{dump_date[:4]}-{dump_date[4:6]}-{dump_date[6:8]}" + + # Download links + url_dictfile = DOWNLOAD_URL_DICTFILE.format(locale) + url_kobo = DOWNLOAD_URL_KOBO.format(locale) + url_stardict = DOWNLOAD_URL_STARDICT.format(locale) + + creation_date = NOW.isoformat() + return release_description[locale].format(**locals()) def guess_prefix(word: str) -> str: