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