Skip to content

Fix stale date program cache when gettext/pgettext resolve differently - #6

Merged
MasonLyons merged 1 commit into
mainfrom
claude/bold-merkle-37fc38
Oct 17, 2026
Merged

MasonLyons merged 1 commit into
mainfrom
claude/bold-merkle-37fc38

Conversation

@MasonLyons

Copy link
Copy Markdown
Owner

Django's _trans resolves gettext and pgettext independently (once, by USE_I18N at first use). trans_state only probed gettext, so after an override_settings(USE_I18N=...) flip the date program cache stayed keyed to 'no i18n' while pgettext_lazy month tables (N, E) translated, serving programs compiled under one language to others. This is what made test_realpage::test_dates fail when run after test_render.

TransState now records both functions' resolution; adds a regression test that fails before the fix.

Verified: pytest both file orders, cargo test, Django suite 6.1/5.2 at 100%.

🤖 Generated with Claude Code

Django's _trans resolves each function once by USE_I18N at first use, so
gettext (trans_null) and pgettext (trans_real) can disagree after an
override_settings flip. trans_state only probed gettext, so the date
program cache stayed keyed to (no i18n) while month tables via
pgettext_lazy were translated: a program compiled under one language was
served for others.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@MasonLyons
MasonLyons merged commit 17efb84 into main Oct 17, 2026
15 checks passed
@MasonLyons MasonLyons mentioned this pull request Oct 17, 2026
@MasonLyons
MasonLyons deleted the claude/bold-merkle-37fc38 branch October 18, 2026 00:08
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.

1 participant