2 unstable releases

0.16.0 Nov 11, 2023
0.15.0 Aug 23, 2023

#171 in Internationalization (i18n)

Download history 67/week @ 2024-01-08 39/week @ 2024-01-15 20/week @ 2024-01-22 14/week @ 2024-01-29 5/week @ 2024-02-05 20/week @ 2024-02-12 33/week @ 2024-02-19 54/week @ 2024-02-26 19/week @ 2024-03-04 22/week @ 2024-03-11 25/week @ 2024-03-18 37/week @ 2024-03-25 62/week @ 2024-04-01 31/week @ 2024-04-08 73/week @ 2024-04-15 63/week @ 2024-04-22

234 downloads per month
Used in 4 crates (via batbox)

MIT license

5KB

BatBox

Collection of commonly useful crates


lib.rs:

Internationalization

Use batbox_i18n::gen!(mod mod_name: "path/to.toml")

Example toml file:

[en]
hello = "Hello"
world = "World"

[ru]
hello = "Привет"
world = "Мир"

Generated code with batbox_i18n::gen!(mod i18n: "hello_world.toml"):

mod i18n {
    struct Locale {
        ..
    }

    fn get(locale: &str) -> Option<&'static Locale> { .. }
    fn get_or_en(locale: &str) -> &'static Locale { .. }

    impl Locale {
        pub fn hello(&self) -> &str { .. }
        pub fn world(&self) -> &str { .. }
    }
}

Dependencies

~0.6–3MB
~64K SLoC