Crate rat_embed_lang

Crate rat_embed_lang 

Source
Expand description

简单的嵌入式多语言框架

使用示例:

use std::collections::HashMap;
use i18n_embed::{set_language, register_translations, t};

// 准备翻译数据
let mut translations = HashMap::new();
let mut hello_translations = HashMap::new();
hello_translations.insert("zh-CN".to_string(), "你好".to_string());
hello_translations.insert("en-US".to_string(), "Hello".to_string());
translations.insert("hello".to_string(), hello_translations);

// 注册翻译数据
register_translations(translations);

// 设置语言
set_language("zh-CN");

// 使用翻译
let hello = t("hello"); // 返回 "你好"

Re-exports§

pub use language::normalize_language_code;
pub use language::get_language_from_env;
pub use i18n::set_language;
pub use i18n::current_language;
pub use i18n::register_translations;
pub use i18n::clear_translations;
pub use i18n::t;
pub use i18n::t_with_lang;
pub use i18n::tf;
pub use i18n::tf_with_lang;
pub use i18n::has_translation;
pub use i18n::has_translation_for_lang;
pub use i18n::get_all_keys;
pub use i18n::get_supported_languages;

Modules§

i18n
language

Macros§

tfm
便捷宏:获取参数化翻译文本