From f38f67b5c7d411d4d0e092922f146ead759f3706 Mon Sep 17 00:00:00 2001 From: Wehrwolfmann Date: Tue, 18 Aug 2026 02:04:01 +0200 Subject: [PATCH] L10n: falls back to English when the auto-detected locale is unsupported --key-language with an empty value (and "language": null in the config) asks for the system locale, not for a specific language. When that locale has no translation, fastfetch aborted with exit 477 instead of printing anything, so the same config broke on every locale outside the twelve supported ones, and under LC_ALL=C variants such as POSIX. Auto-detected locales now fall back to English. An explicitly requested language still errors out, so typos and zh are still reported. --- doc/help.json | 2 +- src/options/display.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/help.json b/doc/help.json index b1cfbfa560..b575aa47bc 100644 --- a/doc/help.json +++ b/doc/help.json @@ -588,7 +588,7 @@ { "long": "key-language", "desc": "Specify the language used for module keys", - "remark": "Leave empty for auto-detection based on the system locale", + "remark": "Leave empty for auto-detection based on the system locale. Unsupported locales fall back to English", "arg": { "type": "enum", "default": "en", diff --git a/src/options/display.c b/src/options/display.c index 36d408f78b..2fb18a3e3a 100644 --- a/src/options/display.c +++ b/src/options/display.c @@ -17,7 +17,9 @@ // @returns offsetof(FFModuleDisplayName, ) // @see src/common/option.h static uint32_t optionParseLanguageString(FFstrbuf* language) { - if (language->length == 0) { + const bool detected = language->length == 0; + + if (detected) { #if !FF_MODULE_DISABLE_LOCALE const char* error = ffDetectLocale(language); if (__builtin_expect(error != nullptr, false)) { @@ -52,7 +54,7 @@ static uint32_t optionParseLanguageString(FFstrbuf* language) { // The language code is expected to be in the format of "en", "en_US", "de", "de_DE", etc. // First try to match the full language code, then try to match just the first two characters (the language part). - // If no match is found, report a language not supported error. + // If no match is found, report a language not supported error, unless the language was auto-detected. // en_US -> offsetof(FFModuleDisplayName, en) // en -> offsetof(FFModuleDisplayName, en) // zh_CN -> offsetof(FFModuleDisplayName, zh_CN) @@ -85,6 +87,10 @@ static uint32_t optionParseLanguageString(FFstrbuf* language) { #pragma GCC diagnostic pop error: + // The user asked for the system locale, not for this specific language. Most locales have no + // translation, so falling back to English is friendlier than aborting fastfetch entirely. + if (detected) return offsetof(FFModuleDisplayName, en); + fprintf(stderr, "Error: Language '%s' is not supported\n", language->chars); exit(477); }