6 releases
Uses new Rust 2024
| new 0.1.5 | Apr 6, 2026 |
|---|---|
| 0.1.4 | Apr 6, 2026 |
| 0.1.3 | Oct 13, 2023 |
| 0.1.2 | Sep 17, 2023 |
#166 in Internationalization (i18n)
5KB
Localization
localization is a lightweight localization implementation written in Rust.
Easy, error on compile time, zero runtime dependency.
Getting Started
Install
[dependencies]
localization = "0.1.5"
[build-dependencies]
localization-build = "0.1.5"
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.
Dependencies
~0.5–1.3MB
~28K SLoC