4 个版本
0.3.5 | 2021年4月7日 |
---|---|
0.3.0 | 2020年10月31日 |
0.2.4 | 2020年8月26日 |
0.2.3 | 2020年8月22日 |
#186 在 国际化 (i18n)
33KB
804 行
本地化器
[dependencies]
localizer= "0.3.0"
适用于 rust 项目的简单本地化库。
示例
cargo run --example %example%
1: ex1
2: ex2
3:
Tic_Tac_Toe 游戏1 Tic_Tac_Toe 游戏2
无-Std
特性 = "no_std"
Cargo.toml
localizer = {version = ..., default-features = false, features = ["no_std"]}
lib.rs
:
无不安全代码
示例
use localizer::*;
const langs_file : &str = "
[langs.ru]
\"ex1\" = \"ПРН{}\"
[langs.en]
\"ex1\" = \"IKA{}\"";
localizer::set_loc_string(langs_file);
//localizator::set_localizer(Localizer::create().file(None).current_lang(Some("ru".to_string())));
localizer::change_localizer(&|x|{x.set_current_lang(Some("ru".to_string()));});
println!("{:?}", localizer::get_by_key(&"ex1"));
let loc = Localizer::create().file(None).current_lang(Some("ru".to_string()));
println!("{:?}", loc.get(&"ex1"));
更多示例
cargo run --example %example%
1:
2:
3:
Tic_Tac_Toe 游戏1 Tic_Tac_Toe 游戏2
无-Std
特性 = "no_std"
Cargo.toml
localizer = {version = ..., default-features = false, features = ["no_std"]}
依赖
~135–485KB