tools/gen-languages: query user locale before falling back to en_US

setlocale(LC_ALL, "") queries the user locale.

setlocale(LC_ALL, NULL) also queries the locale, but not the user
locale. It actually queries the programs locale, which by default is C.

Otherwise the user would need to have en_US.UTF-8 available no matter
what.

Check that derivates UTF8 of C locale aren't used as well.

Bug: https://bugs.gentoo.org/969468
Fixes: 88261f8b4c
Signed-off-by: Alfred Wingate <parona@protonmail.com>
This commit is contained in:
Alfred Wingate 2026-01-31 20:21:27 +02:00 committed by Jehan
parent 3369ebe1e7
commit cae3be98df

View file

@ -280,8 +280,8 @@ gimp_language_store_parser_init (GError **error)
goto cleanup;
}
locale = setlocale (LC_ALL, NULL);
if (g_strcmp0 (locale, "C") == 0 || g_strcmp0 (locale, "POSIX") == 0)
locale = setlocale (LC_ALL, "");
if (g_strcmp0 (locale, "C") == 0 || g_strcmp0 (locale, "POSIX") == 0 || g_str_has_prefix (locale, "C."))
{
/* Note: we do not care about what we set, except not C or POSIX.
* It may be any valid locale. This needs to be set so that this