Server functions
There is no context in server functions, so you can't call use_i18n
. You could provide a context if you want,
and it would work as expected, but if you just want to access what locale the user is using you can use the resolve_locale
function:
#![allow(unused)] fn main() { #[server] async fn get_locale() -> Result<Locale, ServerFnError> { let locale: Locale = leptos_i18n::locale::resolve_locale(); Ok(locale) } }