mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
Merge pull request #713 from mitchellh/fix-unsupported-locale-lang
If the locale isn't supported and falls back to the POSIX/C locale, use en_US.UTF-8
This commit is contained in:
@ -42,7 +42,11 @@ pub fn ensureLocale() void {
|
|||||||
|
|
||||||
if (setlocale(LC_ALL, "")) |v| {
|
if (setlocale(LC_ALL, "")) |v| {
|
||||||
log.info("setlocale after unset lang result={s}", .{v});
|
log.info("setlocale after unset lang result={s}", .{v});
|
||||||
return;
|
|
||||||
|
// If we try to setlocale to an unsupported locale it'll return "C"
|
||||||
|
// as the POSIX/C fallback, if that's the case we want to not use
|
||||||
|
// it and move to our fallback of en_US.UTF-8
|
||||||
|
if (!std.mem.eql(u8, std.mem.sliceTo(v, 0), "C")) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,6 +54,7 @@ pub fn ensureLocale() void {
|
|||||||
// Failure again... fallback to en_US.UTF-8
|
// Failure again... fallback to en_US.UTF-8
|
||||||
log.warn("setlocale failed with LANG and system default. Falling back to en_US.UTF-8", .{});
|
log.warn("setlocale failed with LANG and system default. Falling back to en_US.UTF-8", .{});
|
||||||
if (setlocale(LC_ALL, "en_US.UTF-8")) |v| {
|
if (setlocale(LC_ALL, "en_US.UTF-8")) |v| {
|
||||||
|
_ = setenv("LANG", "en_US.UTF-8", 1);
|
||||||
log.info("setlocale default result={s}", .{v});
|
log.info("setlocale default result={s}", .{v});
|
||||||
return;
|
return;
|
||||||
} else log.err("setlocale failed even with the fallback, uncertain results", .{});
|
} else log.err("setlocale failed even with the fallback, uncertain results", .{});
|
||||||
|
Reference in New Issue
Block a user