Installation

CSR

For client side rendering apps install leptos-fluent and fluent-templates:

[dependencies]
leptos-fluent = "0.2"
fluent-templates = "0.11"
Minimal (recommended)
[dependencies]
leptos-fluent = "0.2"
fluent-templates = { version = "0.11", default-features = false, features = [
  "macros",
  "walkdir"
] }

Using default-features = false and features = ["macros", "walkdir"] for fluent-templates ensures that the dependency tree is the minimal possible because more dependencies are shared between leptos-fluent and fluent-templates.

SSR

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

[dependencies]
leptos-fluent = "0.2"
fluent-templates = "0.11"

[features]
hydrate = [
  "leptos-fluent/hydrate"
]
ssr = [
  "leptos-fluent/ssr",
  "leptos-fluent/actix",  # 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"] }
fluent-templates = "0.11"

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

Nightly toolchain

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

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

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]
fluent-templates = "0.11"
leptos-fluent = { version = "0.2", features = ["json5"], default-features = false }

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.11"

Compatibility

leptos-fluentleptos
0.20.7
0.10.6