Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Source/WTF/wtf/unix/LanguageUnix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@
// always the same value.
static String platformLanguage()
{
// language[_territory][.codeset][@modifier]: only language and territory name a locale. Strip the
// rest first so "C.UTF-8" (glibc, and bionic's default) is recognized as the C locale below.
auto localeDefault = String::fromLatin1(setlocale(LC_CTYPE, nullptr));
if (auto suffix = localeDefault.find([](UChar c) { return c == '.' || c == '@'; }); suffix != notFound)
localeDefault = localeDefault.left(suffix);

Check warning on line 39 in Source/WTF/wtf/unix/LanguageUnix.cpp

View check run for this annotation

Claude / Claude Code Review

Stripping @modifier loses script/variant info that the old ICU fallback preserved

Stripping the `@modifier` turns codeset-less locales like `ca_ES@valencia` into valid BCP 47 (`ca-ES`), so `canonicalizeUnicodeLocaleID()` now accepts them and `defaultLocale()` no longer falls through to `uloc_getDefault()` — which previously re-read the POSIX locale and preserved the modifier as a variant (`ca-ES-valencia`, a registered IANA subtag with real CLDR data). Not worth blocking on — the affected population (codeset-less `@modifier` glibc locales after `setlocale(LC_ALL, "")`) is tin
Comment thread
dylan-conway marked this conversation as resolved.
Resolved
if (localeDefault.isEmpty() || equalIgnoringASCIICase(localeDefault, "C"_s) || equalIgnoringASCIICase(localeDefault, "POSIX"_s))
return "en-US"_s;

auto normalizedDefault = makeStringByReplacingAll(localeDefault, '_', '-');
return normalizedDefault.left(normalizedDefault.find('.'));
return makeStringByReplacingAll(localeDefault, '_', '-');
}

Vector<String> platformUserPreferredLanguages(ShouldMinimizeLanguages)
Expand Down
Loading