Crates.io | leptos_i18n |
lib.rs | leptos_i18n |
version | |
source | src |
created_at | 2023-08-25 21:35:46.093154 |
updated_at | 2024-11-09 01:17:23.034861 |
description | Translations integration helper for the Leptos web framework |
homepage | |
repository | https://github.com/Baptistemontan/leptos_i18n |
max_upload_size | |
id | 955062 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
This crate is made to simplify internationalization in a Leptos application, that loads locales at compile time and provides compile time checks for translation keys, interpolation keys and the selected locale.
The main focus is ease of use with leptos, a typical component using this crate will look like this:
use crate::i18n::*;
use leptos::prelude::*;
#[component]
fn Counter() -> impl IntoView {
let i18n = use_i18n();
let (counter, set_counter) = signal(0);
let inc = move |_| set_counter.update(|count| *count += 1);
view! {
<button on:click=inc>
{t!(i18n, click_to_inc)}
</button>
<p>
{t!(i18n, click_count, count = move || counter.get())}
</p>
}
}
You can add the crate to your project with
cargo add leptos_i18n
Or by adding this line to your Cargo.toml
under [dependencies]
:
leptos_i18n = "0.5"
Leptos | Leptos i18n |
---|---|
< v0.4.x |
not supported |
v0.4.x |
v0.1.x |
v0.5.x |
v0.2.x |
v0.6.x |
v0.3.x / v0.4.x |
v0.7.x |
v0.5.x |
You can look into the Book for documentation, or look for examples on the github repo.