Loon
Loon is a localization/internationalization library, inspired by ruby-i18n.
It use rust-embed for embed the localization assets into your binary.
Usage
Load locales assets by RustEmbed and init Loon in your lib.rs
use RustEmbed;
// Load Loon macro, for allow you use `t!` macro in anywhere.
extern crate loon_embed;
// Use RustEmbed to locale assets
;
You must put I18n YAML files in locales/ folder.
locales/
├── en.yml
├── zh-CN.yml
For example of en.yml:
greeting: Hello world
messages:
hello: Hello, {}
Now you can use t! macro in anywhere.
t!;
// => "Hello world"
t!;
// => "Hello, world"
You can use loon_embed::set_locale or call loon_embed::init agian to change the current locale in runtime.
set_locale;
locale;
// => "zh-CN"
License
MIT