Skip to content
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

Dyn load #139

Merged
merged 39 commits into from
Oct 12, 2024
Merged

Dyn load #139

merged 39 commits into from
Oct 12, 2024

Conversation

Baptistemontan
Copy link
Owner

@Baptistemontan Baptistemontan commented Sep 25, 2024

  • No static strings in the client binary
  • Request translations using server fn
  • Ship used translations with the HTML
  • Fix "interpolate_display" feature
  • Make it work with CSR
  • Update docs

I'll write some docs for the book, but it won't be published so here is a few things to know about the newly added "dynamic_load" feature:

Translations are separated in what I call "translations units", if you don't use namespaces, there is one for each locale, if you use namespaces, the units are the product of namespaces and locales.
The feature remove the translations from the client binary, they are still embedded in the server binary. The server will send the used translations units (only the ones being used) in the sent html, they are parsed when the page hydrate.
When an t unit is used but still isn't loaded, a request is sent to the server and the view will update once that request returns.
For obvious reason, requesting the translations is async, so when using "dynamic_load", most variants of the t! macro will return a future:
t!, td! and tu! will still return a impl Fn() -> impl IntoView, the future is handled inside of it, so you don't need to update anything with those.
t*_string! and t*_display! return a impl Future, where the outputs are Cow<'static, str> and impl Display respectively, if you use those your code will need some updating.
If you use a backend where server functions need to be register manually, there is the ServerFn associated type on the Locale trait that the generated Locale enum implement thta you should register.

@Baptistemontan
Copy link
Owner Author

This is mostly working, two features are not compatible at the moment: "csr" and "interpolate_display"

@Baptistemontan Baptistemontan linked an issue Sep 29, 2024 that may be closed by this pull request
@Baptistemontan
Copy link
Owner Author

Merging this, support for CSR will come later.

@Baptistemontan Baptistemontan marked this pull request as ready for review October 12, 2024 22:14
@Baptistemontan Baptistemontan merged commit e9ca44f into master Oct 12, 2024
25 checks passed
@Baptistemontan Baptistemontan deleted the dyn_load branch October 12, 2024 22:14
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