🔞
r18 is a crate for internationalising Rust projects.
Usage
Add r18 as your project dependency.
[]
= "0.1"
Create a JSON translation file with name BCP 47 language tag as naming format, like below:
// PATH: ./tr/zh-CN.json
Then add r18::init! to the global scope of your code with the directory where translation files in (in following example is ./tr).
init!;
After initialising the r18, use auto_detect! to detect locale and load translation model automatically.
If you want, you can use set_locale! to set locale manually.
After above process, use tr! to get your text which has been translated.
init!;
You can find a complete example here. You can run the example with following command:
cargo run -p example