Expand description
§cntp_i18n_macros
This crate provides the procedural macros for the cntp_i18n system.
These macros are re-exported by cntp_i18n, so you typically don’t need to
depend on this crate directly.
§Macros
tr!- Translate a simple stringtrn!- Translate a plural stringtr_load!- Load translations into anI18nSourcetr_noop!/trn_noop!- Mark strings for extraction without runtime lookup
§Usage
ⓘ
use cntp_i18n::{tr, trn, tr_load, I18N_MANAGER};
fn main() {
// Load translations at startup
I18N_MANAGER.write().unwrap().load_source(tr_load!());
// Simple translation
let greeting = tr!("HELLO", "Hello!");
// Translation with variables
let welcome = tr!("WELCOME", "Welcome, {{name}}!", name = user_name);
// Plural translation
let items = trn!(
"ITEMS",
"{{count}} item",
"{{count}} items",
count = item_count
);
}Macros§
- tr
- Returns a translated string for the given key.
- tr_load
- Generates an
I18nSourcefrom the translation files. - tr_noop
- Marks a string for translation extraction without performing a lookup.
- trn
- Returns a translated, plural-matched string for the given key.
- trn_
noop - Marks a plural string for translation extraction without performing a lookup.