Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Installation

CSR

For client side rendering apps install leptos-fluent:

[dependencies]
leptos-fluent = "0.2"

SSR

For server side rendering apps install leptos-fluent and enable the hydrate, ssr and actix/axum features in their respective features set.

[dependencies]
leptos-fluent = "0.2"

[features]
hydrate = [
  "leptos-fluent/hydrate"
]
ssr = [
  "leptos-fluent/ssr",
  "leptos-fluent/axum",  # actix and axum are supported
]

# Using cargo-leptos
[package.metadata.leptos]
watch-additional-files = ["locales"]

Desktop applications

leptos-fluent can be installed on non-wasm targets, like desktop applications. You need to install leptos-fluent, fluent-templates and enable the system feature:

[dependencies]
leptos-fluent = { version = "0.2", features = ["system"] }

Features

  • Server Side Rendering: ssr
  • Hydration: hydrate
  • Actix Web integration: actix
  • Axum integration: axum
  • Nightly toolchain: nightly
  • Desktop applications: system
  • JSON languages file: json
  • YAML languages file: yaml
  • JSON5 languages file: json5
  • Tracing support: tracing
  • Debugging: debug
  • Disable Unicode isolating marks: disable-unicode-isolating-marks

Nightly toolchain

leptos-fluent builds nightly functionalities by enabling the nightly feature:

[dependencies]
leptos-fluent = { version = "0.2", features = ["nightly"] }

Language files

By default, leptos-fluent supports JSON languages files. To use other formats to load custom languages, the json5 or yaml features can be enabled:

[dependencies]
leptos-fluent = { version = "0.2", features = ["json5"] }

Tip

Tracking locales files with cargo leptos

Using cargo leptos watch of the locales/ folder for reloads:

# Relative to Cargo.toml file
[package.metadata.leptos]
watch-additional-files = ["locales"]

When inside a workspace, use the full path to the folder from the workspace Cargo.toml file:

 # Relative to workspace Cargo.toml file
[package.metadata.leptos]
watch-additional-files = ["examples/csr/locales"]

Tracing

To enable tracing support, add the tracing feature to leptos-fluent:

[dependencies]
leptos-fluent = { version = "0.2", features = ["tracing"] }
fluent-templates = "0.13"

Compatibility

leptos-fluentleptos
0.20.7 / 0.8
0.10.6