26 unstable releases (4 breaking)

0.5.0-gamma2 Oct 24, 2024
0.5.0-beta Sep 17, 2024
0.3.3 Feb 22, 2024
0.2.3 Oct 27, 2023

#1611 in Web programming

Download history 182/week @ 2024-07-17 209/week @ 2024-07-24 73/week @ 2024-07-31 146/week @ 2024-08-07 186/week @ 2024-08-14 230/week @ 2024-08-21 115/week @ 2024-08-28 64/week @ 2024-09-04 284/week @ 2024-09-11 600/week @ 2024-09-18 155/week @ 2024-09-25 85/week @ 2024-10-02 215/week @ 2024-10-09 147/week @ 2024-10-16 346/week @ 2024-10-23 186/week @ 2024-10-30

918 downloads per month
Used in nova-forms

MIT license

145KB
3K SLoC

crates.io

Docs.rs | Book

Leptos i18n

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>
  }
}

Getting started

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"

Version compatibility with leptos

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

How to use

You can look into the Book for documentation, or look for examples on the github repo.

Dependencies

~30–46MB
~734K SLoC