Skip to content

Warn when the UI language's system locale isn't installed - #2469

Open
dsblank wants to merge 2 commits into
gramps-project:masterfrom
dsblank:fix/warn-missing-system-locale
Open

Warn when the UI language's system locale isn't installed#2469
dsblank wants to merge 2 commits into
gramps-project:masterfrom
dsblank:fix/warn-missing-system-locale

Conversation

@dsblank

@dsblank dsblank commented Jul 15, 2026

Copy link
Copy Markdown
Member

Motivation

Currently, gramps displays the following when a language pack is not installed:

(Gramps.py:2401429): Gtk-WARNING **: 05:37:58.349: Locale not supported by C library.
	Using the fallback 'C' locale.

We add the following translatable text:

.gramps.gen.utils.grampslocale.WARNING: Gramps 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 
https://gramps-project.org/wiki/index.php?title=Gramps_6.1_Wiki_Manual_-_Setting_up_language_environment 
for instructions.

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

  • Gramps resolves the chosen UI language to a full system 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, unhelpful warning: Locale not supported by C library. Using the fallback 'C' locale.
  • GrampsLocale now 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 --check on changed files
  • mypy on changed files
  • python3 -m unittest gramps.gen.utils.test.grampslocale_test — all passing, including new LocaleIsInstalledTest cases
  • Manually reproduced: selecting a language whose locale isn't installed now logs Gramps 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

dsblank added 2 commits July 15, 2026 06:44
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.
@hgohel hgohel added Type: Enhancement Status: New A new pull request that is awaiting developer comments before review. labels Jul 16, 2026
@dsblank dsblank added this to the v6.2 milestone Jul 16, 2026
@sam-m888

sam-m888 commented Jul 21, 2026

Copy link
Copy Markdown
Member

https://gramps-project.org/wiki/index.php?title=Gramps_6.1_Wiki_Manual_-_Setting_up_language_environment
for instructions.
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.

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

https://gramps-project.org/wiki/index.php/Gramps_6.0_Wiki_Manual_-_Settings#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

https://gramps-project.org/wiki/index.php/Gramps_6.2_Wiki_Manual_-_Settings#Setting_up_the_language_environment

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

More information can be found at Installing_Gramps_for_Windows_computers#Missing_other_languages page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: New A new pull request that is awaiting developer comments before review. Type: Enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants