From 4c5b7afec592c43d91d4ba0646dcad9cce6976f2 Mon Sep 17 00:00:00 2001 From: Jehan Date: Sun, 23 Nov 2025 12:27:14 +0100 Subject: [PATCH] Issue #13774: languages list is not localized on AppImage. Seems like our CI runners are configured with POSIX locale. Both C and POSIX locales are basically overriding any attempt to localize during the build (setting LANGUAGE doesn't work) and unfortunately we are now self-localizing the list of languages during build. So let's add a bogus en_US.UTF-8 locale before setting LANGUAGE. This should fix the issue. It would probably also fix the same issue for various third-party packages if distributions' build machines are set similarly! (cherry picked from commit 88261f8b4cab65350cd858e9221a91da4c7f86db) --- .gitlab-ci.yml | 3 +++ tools/gen-languages.c | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f314b64065..f20c81af08 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -219,11 +219,14 @@ deps-debian-nonreloc: libwmf-dev libxmu-dev libxpm-dev + locales mypaint-brushes poppler-data python3 python3-gi python3-gi-cairo" >> Dockerfile + - echo "RUN echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen" >> Dockerfile + - echo "RUN locale-gen" >> Dockerfile # Prepare environ - echo "FROM $CI_REGISTRY_IMAGE:build-debian-${DEB_VERSION}-${RUNNER}" > Dockerfile2; - echo "RUN printf \"\e[0Ksection_start:\`date +%s\`:environ[collapsed=true]\r\e[0KPreparing build environment\n\"" >> Dockerfile2; diff --git a/tools/gen-languages.c b/tools/gen-languages.c index dc0cd8c129..ffe5ddd856 100644 --- a/tools/gen-languages.c +++ b/tools/gen-languages.c @@ -278,6 +278,26 @@ 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) + { + /* 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 + * script works even on build systems with C or POSIX locale. In + * these 2 cases only, the LANGUAGE is ignored and our whole + * self-localizing code below would be basically moot. + */ + g_setenv ("LC_ALL", "en_US.UTF-8", TRUE); + if (setlocale (LC_ALL, "") == NULL) + { + g_printerr ("ERROR: %s: setlocale() failed. " + "The build system needs to be set up for localization. " + "Please install at least \"en_US.UTF-8\" or set a locale other than C or POSIX.\n", + __FILE__); + exit (EXIT_FAILURE); + } + } + /* Generate the localized language names. */ g_hash_table_iter_init (&lang_iter, l10n_lang_list); gimp_bind_text_domain ("iso_639_3", ISOCODES_LOCALEDIR);