-
Notifications
You must be signed in to change notification settings - Fork 17.7k
fix(i18n): inject language pack into bootstrap to translate code-split chunks #39357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alex-poor
wants to merge
5
commits into
apache:master
Choose a base branch
from
alex-poor:fix/i18n-bootstrap-injection
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b365c2b
fix(i18n): inject language pack into bootstrap to translate code-spli…
alex-poor 0ecd09b
refactor(i18n): reuse get_language_pack and inject outside per-user m…
alex-poor e553319
test(views): account for language_pack injection in common_bootstrap_…
alex-poor fe86725
fix(i18n): respect override-provided language_pack and drop dead or-None
alex-poor a719a46
docs(i18n): note inline language-pack trade-off in spa.html template
alex-poor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth flagging as a known limitation: embedded doesn't extend
spa.html, so it never gets the injected pack and lands here on the async fetch, which still has the same code-split chunk race this PR is fixing. So embedded dashboards would stay partially translated. Fine to leave for a follow-up, just might be worth a note so it's not assumed covered.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell embedded is actually covered (I think!).
EmbeddedView.embeddedrenderssuperset/spa.htmlwithentry="embedded"and callscommon_bootstrap_payload()(embedded/view.py#L97-L109), so the injectedcommon.language_packand the inline<script>that setswindow.__SUPERSET_LANGUAGE_PACK__(beforejs_bundle(entry)) both apply.addPreamble('src/embedded/index.tsx'), which prependspreamble.ts— so the preferred injected-pack path here runs for embedded too, andTranslatorSingleton.autoConfigureFromWindow()self-configures from the global on the firstt()/tn()regardless.spa.htmlis the only template carryingdata-bootstrap/js_bundle(entry), so every entry goes through this injection.whether an embedded load is actually translated still depends on the resolved locale (
?lang=/session/Accept-Language) being non-English — if it resolves toen, the pack isnulland there's nothing to inject, same as the main app.Let me know if you're seeing it hit the async fetch path in practice, but as far as I can trace it embedded shouldn't.