Installation
- CSR
- SSR
- Desktop applications
- Features
- Nightly toolchain
- Language files
- Tracking locales files with
cargo leptos
- Tracing
CSR
For client side rendering apps install leptos-fluent and fluent-templates
:
[dependencies]
leptos-fluent = "0.1"
fluent-templates = "0.11"
Minimal (recommended)
[dependencies]
leptos-fluent = { version = "0.1", default-features = false }
fluent-templates = { version = "0.11", default-features = false, features = [
"macros",
"walkdir"
] }
- Using
default-features = false
forleptos-fluent
thejson
default feature will not be enabled, so thelanguages
parameter ofleptos_fluent!
macro will not be available. - Using
default-features = false
andfeatures = ["macros", "walkdir"]
forfluent-templates
ensures that the dependency tree is the minimal possible because more dependencies are shared betweenleptos-fluent
andfluent-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.1"
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.1", features = ["system"] }
fluent-templates = "0.11"
See the GTK example.
Features
- Server Side Rendering:
ssr
- Hydration:
hydrate
- Actix Web integration:
actix
- Axum integration:
axum
- Nightly toolchain:
nightly
- Desktop applications:
system
- JSON languages file:
json
(enabled by default) - 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.1", 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.1", features = ["json5"], default-features = false }
See 4. Languages.
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.1", features = ["tracing"] }
fluent-templates = "0.11"
See the GTK example.