Strategies

All the features of the framework are optional, following a declarative "opt-in" configuration method.

Loading the initial language of the user

The initial language of the user can be set in different ways:

StrategyCSRSSRDesktopleptos_fluent!
URL parameterinitial_language_from_url_param
URL pathinitial_language_from_url_path
Cookieinitial_language_from_cookie
Server functioninitial_language_from_server_function
Browser local storageinitial_language_from_localstorage
Browser navigator.languagesinitial_language_from_navigator
Accept-Language headerinitial_language_from_accept_language_header
System languageinitial_language_from_system
Data fileinitial_language_from_data_file

All of them can be defined at the same time or just one of them at the same time. The first language source found will be used and nexts discharged. The order of precedence is:

CSR | Updating the language on the client

When the user changes the language and I18n::language.set is called, the framework can perform a side effect to update the language in the client. The following strategies are available:

Strategyleptos_fluent!
URL parameterset_language_to_url_param
Cookieset_language_to_cookie
Browser local storageset_language_to_localstorage
Server functionset_language_to_server_function

When the user changes the language in the browser settings, the framework can perform a side effect to reflect the language change in the client. The following strategies are available:

Strategyleptos_fluent!
Browser navigator.languagesset_language_from_navigator

featsystem | Desktop applications

Strategyleptos_fluent!
Data fileset_language_to_data_file

CSR | Updating the language from initialization on the client

When a language is loaded from initialization, the framework can perform a side effect to persistently storage the language in the client. The following strategies are available:

Strategyleptos_fluent!
URL parameter to cookieinitial_language_from_url_param_to_cookie
URL parameter to local storageinitial_language_from_url_param_to_localstorage
URL path to cookieinitial_language_from_url_path_to_cookie
URL path to local storageinitial_language_from_url_path_to_localstorage
Cookie to local storageinitial_language_from_cookie_to_localstorage
Local storage to cookieinitial_language_from_localstorage_to_cookie
Local storage to server functioninitial_language_from_localstorage_to_server_function
navigator.languages to cookieinitial_language_from_navigator_to_cookie
navigator.languages to local storageinitial_language_from_navigator_to_localstorage
navigator.languages to server functioninitial_language_from_navigator_to_server_function
Server function to local storageinitial_language_from_server_function_to_localstorage

CSR + SSR

Strategyleptos_fluent!
URL parameter to server functioninitial_language_from_url_param_to_server_function
URL path to server functioninitial_language_from_url_path_to_server_function
Cookie to server functioninitial_language_from_cookie_to_server_function
Server function to cookieinitial_language_from_server_function_to_cookie

featsystem | Desktop applications

Strategyleptos_fluent!
System language to data fileinitial_language_from_system_to_data_file

CSR | Client side effects

When the user updates the language, the framework can perform side effects to update the language in the client. The following side effects are available:

Side effectleptos_fluent!
<html lang="..."> attributesync_html_tag_lang
<html dir="..."> attributesync_html_tag_dir

CSR + SSR | Names

The names of the settings can be configured using the following parameters:

Strategyleptos_fluent!Default value
Cookiecookie_name"lf-lang"
Cookie attributescookie_attrs""
Browser local storagelocalstorage_key"lang"
URL parameterurl_param"lang"
URL path extractor fnurl_path

featsystem | Desktop applications

Strategyleptos_fluent!Default value
Data filedata_file_key"leptos-fluent"