Repository navigation
add i18n support - #6796
add i18n support#6796benedikt-bartscher wants to merge 108 commits into
Conversation
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
[Medium impact] The latest changes appear safe to merge. SummaryAdds optional internationalization through
Reviews (67) · Last reviewed commit: "Prerender each locale route with its own..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6b9a5f5342
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| "reflex-base >= 0.9.7.dev0", | ||
| "reflex >= 0.9.7.dev0", |
There was a problem hiding this comment.
Remove development pins before publishing reflex-i18n
With the new dispatch-release option, selecting reflex-i18n will create a release and trigger .github/workflows/publish.yml, whose publish job runs scripts/check_min_deps.py --check-dev-pins "$PACKAGE" and explicitly rejects published dependencies containing *.dev pins. Because these two requirements are part of reflex-i18n's published metadata, the publish workflow for any reflex-i18n release will fail at that gate until they are pinned to released versions.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I'll leave this open for the maintainers
There was a problem hiding this comment.
Still for the maintainers, but with the current picture after merging main (c00c5ff): reflex itself carries the same kind of pin (reflex-base >= 0.9.12.dev0), so a dev pin in-tree is the normal state and the publish gate is what forces the bump. reflex-i18n's constraint is genuinely unreleased — it needs register_event_scope_provider, register_implicit_dependency and ExpandRoutesContext, all added by this PR — so no published floor would be truthful, and I'd rather not invent one. It uses none of the API #7268 raised floors for. check_min_deps.py reflex-i18n passes; --check-dev-pins reports the pin as expected.
|
@masenf could you please take a brief look at this from an architectural design and DX perspective? it's totally okay if you have smth completly different in mind |
masenf
left a comment
There was a problem hiding this comment.
@benedikt-bartscher thanks for adding this and sorry for the review back-up. i did an initial look and i think the added extension points make sense and the API feels nice.
one potential issue i see affects SEO performance of the SSG static versions of the site -- since the translation depends on state, other languages might not be indexable by crawlers.
e68fb65 to
3e540c0
Compare
There was a problem hiding this comment.
All reported issues were addressed across 15 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 8 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
reflex leaves the optional reflex-i18n names out of __all__ when that package is not installed, as in the isolated environment the build hook generates stubs in. The published reflex/__init__.pyi then stopped re-exporting rx.t and rx.i18n, so pyright rejected them even with reflex-i18n installed. The stub's __all__ now comes from the lazy mappings, through the same exported_names helper attach uses.
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
Patching os.path.relpath also broke Babel's per-file relpath in extract_from_dir, so the test raised before reaching its assertion. It now replaces only the reflex_i18n.cli module's os binding.
Language tags are case-insensitive, as are the router and the server and client segment lookups, so locales such as "en" and "EN" named one route twice and let the server and client resolve it to different spellings.
The per-event scope read i18n_state.router.page.path, which composes a RouterData view and goes through the deprecated RouterData.page accessor (stack walk plus a logged deprecation warning) on every event, cookie mode included, and looked the plugin up twice. Look the plugin up once, read rx_router_route_id only when the plugin routes locales through the URL, and resolve Accept-Language from rx_router_headers in the locale var. Warm event through BaseStateEventProcessor (memory manager): cookie mode 81 -> 32-37 us, URL routing 83-86 -> 34-41 us (no i18n: 23-26 us).
_resolve_plugin re-implemented get_plugin with its own isinstance scan and silently took the first of several I18nPlugin entries. Use get_plugin, so a duplicate raises the same ConfigError as every other lookup.
…pace on Python 3.15
…the deprecated console helpers
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
closes #2339