Closed webhype closed 4 weeks ago
use_init_i18n
is a hook, and therefore you can only call it in Dioxus components. Instead of calling it in your main
function, do it in your root compoennt (app
)
Brilliant, worked like a charm, and makes so much sense lol. The use_ prefix should have given me the hint lol. Thank you for the lighning-fast response!
Can dioxus-i18n be used on server side as well for example to translate text for SSG or SSR pages?
I'm a beginner in Dioxus; the boundaries between what is "web" (client) and what is "server" aren't always clear to me yet.
Can dioxus-i18n be used on server side as well for example to translate text for SSG or SSR pages?
I think so, but I must admit I haven't tried it myself, so maybe there is some edge case that I am not aware of. But in theory it should work just fine, its just components at the end of the day
😄
I added some internationalization to my fullstack web app, and it compiles fine, but panics at runtime with:
called
Result::unwrap()on an
Errvalue: RuntimeError
Here's my compiler output:
$ dx serve --verbose --trace --platform web
One way that I found to avoid this (by trial and error) was to conditionally compile all mentions of
dioxus-i18n
, like so:However, when I do so, there's no "reactivity" going on any more (i.e. the
Link
shown isn't clickable and doesn't switch the language as expected.It seems that the panic happens in
main()
when callinguse_init_i18n()
, here's how I initialize dioxus-i18n:What am I missing?