use_locales
Reactive locales.
If called on the client-side this function returns the value of
navigator.languages
and listens for changes to that property.
See "Server-Side Rendering" below.
Demo
Usage
use leptos::*;
use leptos_use::use_locales;
#[component]
fn Demo() -> impl IntoView {
let locales = use_locales();
view! { }
}
Server-Side Rendering
On the server this returns the parsed value of the accept-language
header.
If you're using
axum
you have to enable the"axum"
feature in your Cargo.toml. In case it'sactix-web
enable the feature"actix"
, forspin
enable"spin"
.
Bring your own header
In case you're neither using Axum, Actix nor Spin, or the default implementation is not to your liking,
you can provide your own way of reading the language header value using the option
UseLocalesOptions::ssr_lang_header_getter
.
Feature
This function is only available if the crate feature
use_locales
is enabled