Skip to main content

Crate dioxus_translate

Crate dioxus_translate 

Source

Macros§

translate

Enums§

Language

Constants§

STORAGE_KEY

Traits§

Translate
Translator

Functions§

language_from_cookie
Reads the language from the language cookie in the current HTTP request. Uses FullstackContext::current() to access request headers during SSR. Returns Language::default() if no context or cookie is found.
set_initial_language
Overwrite the global language signal. Used by the app-level persistence layer to restore a saved preference on startup before any component renders reading the signal.
set_language
Sets the global language signal value.
translate
use_language
On non-wasm targets the same binary runs both the SSR server and native clients (desktop / mobile). Distinguish them at runtime via FullstackContext: if a fullstack request context exists we’re handling an HTTP render and should read the language from the request cookie; if not we’re a native client and the language lives in the global LANGUAGE signal — the same source of truth as web — hydrated from the WebView’s localStorage by the app layer on startup.
use_translate

Derive Macros§

Translate
Implements a custom derive macro for Translate, which automatically generates a translate(&self, lang: &Language) -> &'static str method for enums.