Codex/windows gtk translations
(AI PR, no human here)
Context
While investigating #12689, we found that delayed GTK initialization reset the
Windows process locale from the correct regional locale to C.
That part was addressed by 53fa412c, which calls Gtk.disable_setlocale() and
prevents GTK from overwriting the locale initialized by Gajim.
During follow-up testing, GTK's own translations still did not work. This PR documents and proposes fixes for two independent causes found in the Windows runtime and packaging.
Observed problems
1. GTK message lookup remains in the C locale
On Windows, Python successfully initializes the regional locale:
LC_TIME=English_Belgium.1252
GNU libintl additionally uses the LC_MESSAGES category. Without an explicit
value, GTK message lookup behaves as though that category is C.
Gajim currently sets LANGUAGE, which is sufficient for its Python gettext
lookup, but it does not provide the category-specific environment value used by
GTK/libintl.
Using LANG is not suitable here: GTK's setlocale(LC_ALL, "") would apply the
UI language to every locale category and would once again replace regional
settings such as LC_TIME.
2. GTK and libadwaita catalogs are removed from the bundle
The MSYS2 GTK and libadwaita packages install catalogs such as:
share/locale/fr/LC_MESSAGES/gtk40.mo
share/locale/fr/LC_MESSAGES/libadwaita.mo
The Windows cleanup currently keeps an LC_MESSAGES directory only when it
contains gajim.mo.
Gajim's catalogs are no longer installed there. They are built into:
gajim/data/locale/<language>/LC_MESSAGES/gajim.mo
Consequently, the cleanup condition fails for every shared locale directory and removes all dependency catalogs, including GTK and libadwaita translations.
Proposed solution
Set only the message-language category
On Windows, set:
LANGUAGE=<Gajim UI language>
LC_MESSAGES=<first Gajim UI language>
LC_MESSAGES is category-specific, so this enables GTK/libintl message lookup
without changing LC_TIME, LC_NUMERIC, or other regional categories.
An explicitly configured LC_MESSAGES value is preserved.
This relies on the existing Gtk.disable_setlocale() call in main.py to stop
GTK from subsequently applying setlocale(LC_ALL, "").
Preserve catalogs for languages supported by Gajim
The Windows cleanup now checks Gajim's actual packaged locale directory when deciding which dependency catalogs to retain.
Matching uses the base language so naming differences between translation projects are handled, for example:
-
nbandnb_NO -
sr@latinandsr@Latn
Catalogs for languages not provided by Gajim are still removed, limiting the bundle-size increase.
Validation
Tested with the existing portable Windows build and its bundled Python/GTK runtime.
-
LC_TIMEremainedEnglish_Belgium.1252. - With the French GTK catalog restored,
_Canceltranslated toA_nnuler. - Without the catalog, the same lookup remained
_Cancel. - Focused unit tests cover:
- deriving
LC_MESSAGESfrom aLANGUAGEpriority list; - preserving an explicitly configured
LC_MESSAGES.
- deriving
- A cleanup fixture using real MSYS2 GTK catalogs verified:
- French was retained;
-
nbwas retained through Gajim'snb_NOtranslation; - unsupported Finnish was removed.
- Python compilation, Bash syntax checking, and
git diff --checkpassed.
Limitations / review points
A complete Windows installer rebuild was not run, so the resulting installer size has not been measured.
The intent of this PR is also to make the two failure modes and the proposed separation of locale categories reviewable. If there is a preferred GLib/gettext-specific initialization mechanism, the runtime part can be adjusted while keeping the same constraints:
- GTK must not overwrite the Windows regional locale;
- GTK gettext must have a non-
Cmessage language; - the corresponding dependency catalogs must be present.