Skip to content

neodyland/localization

Repository files navigation

Localization

GitHub crates.io crates.io

localization is a lightweight localization implementation written in Rust.

Easy, error on compile time, zero runtime dependency by default.

The localization crate supports no_std with the alloc feature. In that configuration, all! uses hashbrown for its generated maps.

Getting Started

Install

[dependencies]
localization = "0.1"
[build-dependencies]
localization-build = "0.1"

Create files

// translations/en-US/default.json
{
    "hello": "Hello {{name}}, you are {{age}} years old!"
}
// build.rs
fn main() {
    localization_build::set_root("./translations");
    localization_build::set_default_locale("en-US");
}
// main.rs
fn main() {
    let name = "John";
    let age = 42;
    let s = t!("en-US","default:hello", name, age);
    println!("{}", s);
    // output: Hello John, you are 42 years old!
}

License

Distributed under the MIT License. See https://github.com/neodyland/localization/blob/master/LICENSE for more information.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Contributors

Languages