Skip to content

Honor custom catalog paths when activating translations - #451

Open
muneikh wants to merge 1 commit into
python-humanize:mainfrom
muneikh:fix-custom-translation-catalog-cache
Open

muneikh wants to merge 1 commit into
python-humanize:mainfrom
muneikh:fix-custom-translation-catalog-cache

Conversation

@muneikh

@muneikh muneikh commented Oct 11, 2026

Copy link
Copy Markdown

Activating the same locale from a second catalog directory currently keeps using the first directory’s translation. Load explicit catalog paths through gettext’s file cache and store the active translation in thread-local state, while retaining the existing default-catalog cache.

The regression uses two real GNU catalogs and checks switching between both directories through activate() and apnumber(). It fails before the fix. With locale catalogs compiled, the full suite passes (857 tests); Ruff, Black and focused Mypy checks pass.

@Wkhanex Wkhanex left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two real temporary gettext catalogs for the same locale now remain distinct by path. Switching A→B→A selects the expected translation, a worker thread can activate B without changing the main thread’s A, and deactivation restores the untranslated text. Explicit custom paths do not enter the default-path cache.

Checked ecc61d994fa6 with 7 standalone assertions on Python 3.12.14. I haven't run the full suite. The generated _version module was supplied as metadata only.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants