Warn when the UI language's system locale isn't installed - #2469
Conversation
Gramps resolves the chosen UI language to a full locale (e.g. "fi_FI.UTF-8") and writes it into LANG for Gtk to pick up. If that locale isn't actually installed, Gtk's own setlocale(LC_ALL, "") call silently falls back to the 'C' locale, printing only a generic "Locale not supported by C library. Using the fallback 'C' locale." warning with no indication of what's missing or how to fix it. GrampsLocale now probes for this ahead of time and, once translations are available, logs a translatable warning naming the missing locale, the language that needed it, and a wiki link with instructions.
Gramps was still writing the unavailable locale into LANG even after detecting it was missing, so Gtk's own setlocale(LC_ALL, "") call during initialization rejected it and printed its own opaque "Locale not supported by C library. Using the fallback 'C' locale." warning, duplicating the clearer one Gramps had just logged. Leave LANG untouched in that case instead, so it keeps whatever valid value the environment already provided and Gtk's own call succeeds without complaint.
I've added a stub section on the settings page in the 6.0 user manual that already has a number of sections on languages that can be cleaned up and simplified later on for the 6.2 release. I've also changed the section name from Setting_up_language_environment to Setting_up_the_language_environment When I roll over the user manual for 6.1 the link will work correctly and be available for the 6.2 release as What information should go into that section please, has it been written? I've created a windows section and duplicated the existing message for windows installs that don't install all the languages
|
Motivation
Currently, gramps displays the following when a language pack is not installed:
We add the following translatable text:
Note: That URL doesn't exist, but I couldn't find a page that would be helpful. We should remove the URL or fill that page in.
Summary
fi_FI.UTF-8) and writes it intoLANGfor Gtk to pick up.setlocale(LC_ALL, "")call silently falls back to the'C'locale, printing only a generic, unhelpful warning:Locale not supported by C library. Using the fallback 'C' locale.GrampsLocalenow probes for this ahead of time (_locale_is_installed()), and once translations are available (they aren't yet this early in construction), logs a translatable warning naming the missing locale, the language that needed it, and a wiki link with instructions on how to install it.Test plan
black --checkon changed filesmypyon changed filespython3 -m unittest gramps.gen.utils.test.grampslocale_test— all passing, including newLocaleIsInstalledTestcasesGramps could not find the system locale fi_FI.UTF-8 needed for the language fi. Dates, numbers, and sorting may not display correctly until it is installed. See <wiki-url> for instructions.instead of Gtk's opaque message; an installed language stays silent.🤖 Generated with Claude Code