Skip to content

Commit

Permalink
Update release descriptions (related to #409)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoboTiG committed Dec 19, 2020
1 parent 739a263 commit 3caf928
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 36 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion wikidict/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions wikidict/lang/ca/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sup>:floppy_disk:</sup>]({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)
<sub>Actualitzat el {creation_date}</sub>
""" # noqa
Expand Down
7 changes: 4 additions & 3 deletions wikidict/lang/en/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sup>:floppy_disk:</sup>]({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)
<sub>Updated on {creation_date}</sub>
""" # noqa
Expand Down
7 changes: 4 additions & 3 deletions wikidict/lang/es/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sup>:floppy_disk:</sup>]({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)
<sub>Actualizado el {creation_date}</sub>
""" # noqa
Expand Down
7 changes: 4 additions & 3 deletions wikidict/lang/fr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sup>:floppy_disk:</sup>]({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)
<sub>Mis à jour le {creation_date}</sub>
""" # noqa
Expand Down
7 changes: 4 additions & 3 deletions wikidict/lang/pt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sup>:floppy_disk:</sup>]({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)
<sub>Actualizado em {creation_date}</sub>
""" # noqa
Expand Down
7 changes: 4 additions & 3 deletions wikidict/lang/sv.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@
Ord räknas: {words_count}
Dumpa Wiktionary: {dump_date}
Installation:
Tillgängliga filer:
1. Kopiera filen [dicthtml-{locale}.zip <sup>:floppy_disk:</sup>]({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)
<sub>Uppdaterad på {creation_date}</sub>
""" # noqa
Expand Down
34 changes: 18 additions & 16 deletions wikidict/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 3caf928

Please sign in to comment.