Commit 539144c
committed
fix(i18n): resolve ISO 639-2/B language codes instead of showing "Unknown"
LANGUAGE_NAMES is keyed on ISO 639-2/T ('deu', 'fra', 'nld'). The 20
bibliographic variants ('ger', 'fre', 'dut') were absent from all 28
locale tables, so a book carrying one missed the lookup entirely.
Two user-visible surfaces:
* display - the book detail page, language browse list, edit form,
magic shelves and OPDS all rendered "Unknown", and every lookup
wrote an ERROR line, once per book per page load;
* upload - get_valid_language_codes_from_code() fell the code through
to *remainder*, which edit_book_languages(upload_mode=True) turns
into ValueError("'ger' is not a valid language"), so an EPUB whose
OPF declares 'ger' was rejected.
Adds ISO6392B_TO_T, consulted on miss by _resolve_lang_code(), plus a
canonical_lang_code() normalizer; the validation path now accepts /B
input and stores the /T form. The table is written out rather than
derived from pycountry - 639-2/B is a closed list, and deriving it
would let a packaging change silently empty the map - with a test
pinning it against pycountry as a drift alarm.
Unmappable codes now log at WARNING: an unrecognised code is a property
of the book's metadata, not an application fault.
21 new tests plus the 3 pre-written smoke tests un-quarantined. For #1109.1 parent 847c9c4 commit 539144c
5 files changed
Lines changed: 279 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
0 commit comments