diff --git a/examples/share-i18n/crates/app/src/main.rs b/examples/share-i18n/crates/app/src/main.rs new file mode 100644 index 0000000..e69de29 diff --git a/examples/share-i18n/crates/i18n/src/lib.rs b/examples/share-i18n/crates/i18n/src/lib.rs new file mode 100644 index 0000000..155ad4f --- /dev/null +++ b/examples/share-i18n/crates/i18n/src/lib.rs @@ -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) + } +} diff --git a/examples/share-i18n/locales/i18n.yml b/examples/share-i18n/locales/i18n.yml new file mode 100644 index 0000000..ebd3f2b --- /dev/null +++ b/examples/share-i18n/locales/i18n.yml @@ -0,0 +1,4 @@ +_version: 2 +hello: + en: Hello world. + zh-CN: Hello δΈ–η•Œγ€‚ \ No newline at end of file