leptos_use

Function use_locales

Source
pub fn use_locales() -> Signal<Vec<String>>
Expand description

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

Link to Demo

§Usage

let locales = use_locales();

§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’s actix-web enable the feature "actix", for spin 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 crate::UseLocalesOptions::ssr_lang_header_getter.