Theseus 0.3.62: picker says just "English", not "American English"

Intl.DisplayNames.of("en-US") returns "American English", which spells out a
distinction the picker doesn't make — one row per language, with English the
UK original. Pass the base code to Intl so the chip tooltip, the "Automatic
(…)" label and the Settings hint all read as the plain language name
(English, Russian, Portuguese, Chinese) regardless of which regional variant
the OS or the saved setting happens to be.
This commit is contained in:
Silent Mode 2026-10-01 22:14:38 +02:00
parent 93828a0172
commit f4514946bd
4 changed files with 17 additions and 9 deletions

View file

@ -724,7 +724,11 @@
let systemLocaleCached = "en-US";
function short(tag) { return String(tag || "").split("-")[0].toUpperCase().slice(0, 2) || "??"; }
function langName(tag) {
try { return new Intl.DisplayNames(["en"], { type: "language" }).of(tag) || tag; }
// Base language only: "en-US" → "English", not "American English". The
// picker's one row per language already encodes "which English"; the chip
// tooltip just needs the plain name.
const base = String(tag || "").split("-")[0];
try { return new Intl.DisplayNames(["en"], { type: "language" }).of(base) || tag; }
catch { return tag; }
}
function renderLang(s) {

View file

@ -4108,10 +4108,13 @@ function setWebsiteLanguage(mode, value) {
applyAcceptLanguage();
try { chrome?.webContents.send("settings-update", settings); } catch {}
}
// Human-readable name for a BCP-47 tag ("de" → "German") via V8 Intl.
// Falls back to the tag itself if the locale isn't recognised.
// Human-readable name for a BCP-47 tag — the plain language name, no regional
// qualifier ("en-US" → "English", not "American English"). The picker only
// shows one entry per language, so the regional half of a tag is noise in
// labels; pass the base ("en") to Intl.DisplayNames to get the clean name.
function languageNameFor(tag) {
try { return new Intl.DisplayNames(["en"], { type: "language" }).of(tag) || tag; }
const base = String(tag || "").split("-")[0];
try { return new Intl.DisplayNames(["en"], { type: "language" }).of(base) || tag; }
catch { return tag; }
}
ipcMain.handle("system-locale", () => app.getLocale() || "en-US");

View file

@ -1,6 +1,6 @@
{
"name": "theseus-navigator",
"version": "0.3.61",
"version": "0.3.62",
"license": "MPL-2.0",
"description": "Theseus Navigator — a browser that follows the thread. By Silent Mode, a Deviant project.",
"author": "Silent Mode",

View file

@ -1013,11 +1013,12 @@
{ tag: "he-IL", label: "עברית" },
{ tag: "zh-TW", label: "中文(繁體)" },
];
// "English" for a locale tag ("en-US" → "English", "de-DE" → "German") via
// browser Intl. Used for the "Automatic (…)" label so it reads as a
// language name rather than a raw tag.
// Plain language name for a locale tag — no regional qualifier so en-US
// reads as "English", not "American English" (one picker row per language,
// so the regional half is noise). Pass just the base to Intl.DisplayNames.
const langNameFor = (tag) => {
try { return new Intl.DisplayNames(["en"], { type: "language" }).of(tag) || tag; }
const base = String(tag || "").split("-")[0];
try { return new Intl.DisplayNames(["en"], { type: "language" }).of(base) || tag; }
catch { return tag; }
};
(async () => {