Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When one Babel instance initializes two Flask apps,
Babel.domain_instancecaches the first app’s Domain on the shared extension. Requests to the second app can therefore use the first app’s translation catalog and domain, even though the rest of its Babel configuration is application-specific. This is reproducible through ordinary Flask requests rendering Jinja gettext and calling ngettext.Cache the default Domain on the existing application-owned BabelConfiguration and have Babel.domain_instance delegate to it. This preserves catalog reuse across requests while separating applications and resetting the cache when an app is reinitialized. No global application registry or per-request catalog reload is needed. This addresses a remaining translation-cache path in the multi-app use case from #107.
Five regression cases fail on current master and pass with this change. They use compiled catalogs and cover equal/different domains, both first-request orders, repeated requests and loader call counts, nested contexts, reinitialization, and an explicit request-local Domain override.
Validation on Python 3.8 and 3.12: 35 tests pass, with 3 pre-existing list-translations ordering failures. The unchanged base has those exact same 3 failures (30 passing); #242 separately addresses that ordering. Black 24.4.2 checks the whole repository successfully and the Sphinx documentation builds. Windows/macOS/PyPy were not run locally.
Developed and tested with OpenAI Codex assistance.