Crates.io | localization-build |
lib.rs | localization-build |
version | 0.1.3 |
source | src |
created_at | 2023-09-05 12:01:52.799745 |
updated_at | 2023-10-13 04:30:42.863621 |
description | t! macro, the easiest way. |
homepage | |
repository | https://github.com/neodyland/localization |
max_upload_size | |
id | 964181 |
size | 2,912 |
localization is a lightweight localization implementation written in Rust.
Easy, error on compile time, zero runtime dependency.
[dependencies]
localization = "0.1.2"
[build-dependencies]
localization-build = "0.1.2"
// 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!
}
The documentation is available on docs.rs.
Distributed under the MIT License. See LICENSE for more information.