-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example for share I18n in entire workspace.
- Loading branch information
Showing
3 changed files
with
19 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
_version: 2 | ||
hello: | ||
en: Hello world. | ||
zh-CN: Hello 世界。 |