Crate easy_i18n

source ·
Expand description

A easy i18n tool

Example

use easy_i18n::{self, i18n, I18N};
use std::path::Path;
// load source
easy_i18n::set_source(Path::new("./src/source"));
// set lang
easy_i18n::set_lang("EN");

i18n!("这是一个测试"); // This is a test

// Sometimes, the same text has different translation results in different contexts. At this time, we can set different namespaces
i18n!("这是一个测试", ns="namespace1"); // This is a test, but it is different

// If there is a dynamic value in the text, we can use %1, %2, %3.. as a placeholder, where the number represents the position of the dynamic value
i18n!("他的成绩是,语文:%1, 数学:%2", 88, 100); // His grades are Chinese: 88, Mathematics: 100

// If you have different translation results in other contexts, you can set the namespace
i18n!("他的成绩是,语文:%1, 数学:%2", ns="namespace1", 88, 100); // His grades are Chinese: 88, Mathematics: 100, and the test is not bad.

Macros

Structs

Statics

Functions