loon-embed 0.5.0

I18n for Rust, support embed YAML, JSON.
Documentation
# Loon

[![CI](https://github.com/longbridgeapp/loon/actions/workflows/ci.yml/badge.svg)](https://github.com/longbridgeapp/loon/actions/workflows/ci.yml) [![Docs](https://docs.rs/loon-embed/badge.svg)](https://docs.rs/loon-embed/) [![Crates.io](https://img.shields.io/crates/v/loon-embed.svg)](https://crates.io/crates/loon-embed)

Loon is a localization/internationalization library, inspired by [ruby-i18n](https://github.com/ruby-i18n/i18n).

It use [rust-embed](https://crates.io/crates/rust-embed) for embed the localization assets into your binary.

### Usage

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.
#[macro_use]
extern crate loon_embed;

// Use RustEmbed to locale assets
#[derive(RustEmbed)]
#[folder = "locales/"]
#[include = "*.yml"]
struct Asset;

fn main() {
    loon_embed::init::<Asset>("en");
}
```

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"
```

### License

MIT