Skip to content

Commit

Permalink
Add example for share I18n in entire workspace.
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee authored Jun 1, 2024
1 parent 33f5fca commit 4eabf5c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Empty file.
15 changes: 15 additions & 0 deletions examples/share-i18n/crates/i18n/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use rust_i18n;

rust_i18n::i18n!("locales", fallback = "en");

pub struct Backend;

impl rust_i18n::Backend for Backend {
fn available_locales(&self) -> Vec<&str> {
_RUST_I18N_BACKEND.available_locales()
}

fn translate<'a>(&'a self, locale: &str, key: &str) -> Option<&str> {
_RUST_I18N_BACKEND.translate(locale, key)
}
}
4 changes: 4 additions & 0 deletions examples/share-i18n/locales/i18n.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
_version: 2
hello:
en: Hello world.
zh-CN: Hello 世界。

0 comments on commit 4eabf5c

Please sign in to comment.