localization

Crates.iolocalization
lib.rslocalization
version0.1.3
sourcesrc
created_at2023-09-05 12:01:45.007765
updated_at2023-10-13 04:30:55.820533
descriptiont! macro, the easiest way.
homepage
repositoryhttps://github.com/neodyland/localization
max_upload_size
id964180
size2,889
(Googlefan256)

documentation

https://docs.rs/localization

README

Localization

GitHub crates.io crates.io

localization is a lightweight localization implementation written in Rust.

Easy, error on compile time, zero runtime dependency.

Getting Started

Install

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

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

Documentation

The documentation is available on docs.rs.

License

Distributed under the MIT License. See LICENSE for more information.

Commit count: 11

cargo fmt