Skip to content

Commit 539144c

Browse files
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

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ is for things you can see or feel when running the app.
2323

2424
### Fixed
2525

26+
- **Books whose language is written as `ger`, `fre` or `dut` now show that language instead of "Unknown".** A language can be recorded two ways in book metadata: `deu`/`fra`/`nld`, which is what Calibre normally writes, or `ger`/`fre`/`dut`, which is what library-catalogue records and some EPUB files carry. Only the first form was recognised, so a book using the second showed "Unknown" as its language on the book page and in the language list, and importing one could be rejected outright with "'ger' is not a valid language". Both forms are now accepted for all twenty languages where they differ — German, French, Dutch, Chinese, Czech, Greek, Icelandic, Persian, Welsh and the rest. The log line this produced on every single lookup has also been lowered from an error to a warning, since a language code we don't recognise is a detail of the book's metadata and not a fault in the server ([#1109](https://github.com/new-usemame/Calibre-Web-NextGen/issues/1109)).
27+
2628
- **Two people using the library at once no longer break each other's pages.** The server kept one working copy of your library data and shared it across every request it was handling. As soon as any one page finished, it closed that copy, so any other page still being built lost the books it had already read and failed. In the log it showed up as `Instance ... is not persistent within this Session`, pointing at whatever the unlucky page happened to be doing at the time, which made it look like a different bug on every occurrence. It got likelier the busier the server was, so it hit big libraries, shared instances and anything running during an import hardest. Each request now keeps its own working copy ([#1150](https://github.com/new-usemame/Calibre-Web-NextGen/issues/1150)).
2729
- **A page you are reading no longer breaks because a background job finished.** Duplicate scans, thumbnail generation, metadata backups and Hardcover syncs all share the server's connection to your library, and when one of them finished it could close that connection while a page you had open was still reading from it. The page then failed, usually with `Cannot operate on a closed database` in the log. It was intermittent by nature — it only bit when the timing overlapped, which is why a manual scan could break browsing once and then work fine on the next try. Background jobs and page loads now keep their own handle on the library, so one finishing can no longer interrupt the other ([#1121](https://github.com/new-usemame/Calibre-Web-NextGen/issues/1121), reported downstream of [#1048](https://github.com/new-usemame/Calibre-Web-NextGen/issues/1048) by [@auspex](https://github.com/auspex)).
2830

0 commit comments

Comments
 (0)