2 unstable releases

0.16.0 Nov 11, 2023
0.15.0 Aug 23, 2023

#252 in Internationalization (i18n)

Download history 54/week @ 2024-06-02 40/week @ 2024-06-09 39/week @ 2024-06-16 42/week @ 2024-06-23 16/week @ 2024-06-30 11/week @ 2024-07-07 29/week @ 2024-07-14 28/week @ 2024-07-21 33/week @ 2024-07-28 24/week @ 2024-08-04 33/week @ 2024-08-11 20/week @ 2024-08-18 35/week @ 2024-08-25 50/week @ 2024-09-01 63/week @ 2024-09-08 93/week @ 2024-09-15

243 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–3.5MB
~65K SLoC