#localization

no-std localizer

Simple library for localization

3 unstable releases

0.3.0 Oct 31, 2020
0.2.4 Aug 26, 2020
0.2.3 Aug 22, 2020

#33 in Internationalization (i18n)

MIT license

29KB
740 lines

Simple library for localization used in rust projects.

Examples:

1:

use localizer::*;
const langs_file : &str = "
[langs.ru]
\"ex1\" = \"ПРН\"

[langs.en]
\"ex1\" = \"IKA\"";
localizer::set_loc_string(langs_file);
assert!(localizer::get_by_key("ex1") == "IKA");
localizer::change_localizer(&|x|{x.set_current_lang(Some("ru".to_string()));});
assert!(localizer::get_by_key("ex1") == "ПРН");

2:

use localizer::*;
const langs_file : &str = "
[langs.ru]
\"ex1\" = \"ПРН\"

[langs.dsd]
\"ex1\" = \"saПРA\"

[langs.en]
\"ex1\" = \"IKA\"";
localizer::set_loc_string(langs_file);
assert!(localizer::get_by_key3("ex1") == vec!["ПРН".to_string(), "saПРA".to_string(), "IKA".to_string(),]);

3:

Tic_Tac_Toe game

4:

And more in examples


lib.rs:

Simple library for localization.

no unsafe code

Example:

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"));

Dependencies

~660KB
~15K SLoC