Skip to content

webhttrack ignores LC_ALL/LC_MESSAGES and picks the wrong Chinese and Portuguese#616

Merged
xroche merged 3 commits into
masterfrom
fix-webhttrack-locale
Jul 17, 2026
Merged

webhttrack ignores LC_ALL/LC_MESSAGES and picks the wrong Chinese and Portuguese#616
xroche merged 3 commits into
masterfrom
fix-webhttrack-locale

Conversation

@xroche

@xroche xroche commented Jul 16, 2026

Copy link
Copy Markdown
Owner

webhttrack resolved the caller's locale into HTSLANG from LC_MESSAGES/LC_ALL/LANG, then threw that away on the next line by recomputing it from $LANG alone. So LC_ALL and LC_MESSAGES were dead: with only LC_ALL=fr_FR.UTF-8 set you got English. The same line also cut the region off with cut -f1 -d'_', which left the zh_tw and pt_br rows of lang.indexes unreachable, so Traditional Chinese fell back to Simplified and Brazilian Portuguese to European Portuguese. One line, both bugs.

The locale is now resolved in POSIX precedence order (LC_ALL over LC_MESSAGES over LANG) and looked up region-first with a fallback to the bare language. That is the policy lang.indexes already implies by carrying both zh_tw and zh; nothing new is invented here. Honouring LC_ALL does mean LC_ALL=C now wins over a set LANG, so someone with LC_ALL=C and LANG=fr_FR.UTF-8 moves from French to English. That is the POSIX-correct reading of what they asked for, and it is the widest behaviour change here.

While checking the region lookup I found Slovenian's ISO 639-1 code is simply wrong in the data: lang.indexes and Slovenian.txt both say si, which is Sinhala. sl_SI users got English, and since htsserver feeds LANGUAGE_ISO into <html lang=...>, the served pages announced themselves as Sinhala too. Fixed in both files, byte-wise so Slovenian.txt's legacy-charset bytes survive untouched.

tests/61_webhttrack-locale.test lifts the locale block out of the launcher and drives it, so it exercises the shipped code rather than a reimplementation of it. On master it fails at zh_TW (want 14, got 13); with the fix the whole table passes. fr_FR maps correctly on master as well, so the test is not just failing everything put in front of it.

This does not close #95 (select system's language by default). The lookup only covers locales lang.indexes already lists, and choosing a language for an unlisted locale remains a policy call for the maintainer.

xroche added a commit that referenced this pull request Jul 16, 2026
#616 already takes 61.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
@xroche
xroche force-pushed the fix-webhttrack-locale branch from a62bcbb to 5dcabec Compare July 17, 2026 04:48
xroche and others added 3 commits July 17, 2026 07:06
The launcher resolved LC_MESSAGES/LC_ALL/LANG into HTSLANG, then immediately
overwrote it with a value recomputed from $LANG alone, so LC_ALL and
LC_MESSAGES were ignored: a user with only LC_ALL=fr_FR.UTF-8 set got English.
That same line cut the region off with "cut -f1 -d'_'", leaving the zh_tw and
pt_br entries of lang.indexes unreachable, so Traditional Chinese fell back to
Simplified and Brazilian Portuguese to European Portuguese.

Resolve the locale in POSIX precedence order and look the tag up region-first,
falling back to the bare language. Also fix Slovenian's ISO 639-1 code, which
was "si" (Sinhala) in both lang.indexes and Slovenian.txt: sl_SI users got
English, and the served pages claimed lang="si".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
The lift ended at the first blank line, so a blank line grown inside the
locale block would truncate it: reinstating the old LANG-only bug below one
left the test passing 14/14 while the launcher returned English. Anchor on
the next section instead, and pin exported-empty as unset, which lang_of
cannot express.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
@xroche
xroche force-pushed the fix-webhttrack-locale branch from 5dcabec to 52d790b Compare July 17, 2026 05:06
@xroche
xroche merged commit ce481ef into master Jul 17, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Select systems language by default

1 participant