-
Notifications
You must be signed in to change notification settings - Fork 10
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
Issue with leptos_fluent and Islands feature in Leptos #245
Comments
Is the expected behaviour. In islands mode, only
This statement is not totally true. Your code creates an instance on the server (inside You'll probably end shipping a lot of translations to the client if you use the same Another thing that I think that you're concerned about is how to define the same arguments for both instances. Well, note that some of the arguments only have sense for the server and others for the client. As examples, Note in your example that you're providing the leptos_fluent!{ ... }; let i18n = leptos_fluent!{ ... };
provide_context(i18n); If you want the same instance parameters in all islands, just provide one with macro_rules! i18n {
($translations:expr$(,)?) => {
leptos_fluent! {
translations: [$translations],
// ... rest of your arguments
}
};
} Probably there are bugs or quirks that I'm not aware about because I didn't used this mode so much. Feel free to open a PR with an island example or documentation about that, it would be really useful for other users. |
I've submitted a pull request with an islands example. While there are still some areas for improvement, it provides a foundation to build upon. |
Hello,
I'm trying to implement islands in one of my websites, and I've encountered an issue while using
leptos_fluent
with the islands feature. I’ve already opened an issue in the main Leptos repo regarding my initial problem, and after resolving it, I ran into this issue withleptos_fluent
.Here’s what I’ve done so far:
cargo leptos new --git leptos-rs/start-axum
.Cargo.toml
, added the"experimental-islands"
feature toleptos
andleptos_axum
.src/lib.rs
, replacedleptos::mount_to_body(App);
withleptos::leptos_dom::HydrationCtx::stop_hydrating();
.leptos-fluent
dependencies inCargo.toml
:In
src/app.rs
, replaced#[component]
with#[island]
for theHomePage
function.Ran
cargo leptos watch
and verified that the site works as expected, with the counter incrementing on button click.In
src/app.rs
, added the following translations setup:And inside the
App()
function:HomePage
function:However, when I visit the website, I get the following error in the browser console, and the button no longer works:
I’ve managed to make it work by replacing, in
HomePage
,with
However, this creates a new i18n instance, which differs from the one provided in App, making it inconvenient to manage translations consistently. (I can even remove the
i18n
parameter from themove_tr!
, and simply use theleptos_fluent!
macro without assigning it to a variable.)Do you have any suggestions on how to resolve this? I’d be happy to submit a PR with an example of
leptos_fluent
working alongside islands if we can find a good solution.Thanks in advance for your help!
The text was updated successfully, but these errors were encountered: