1 unstable release
Uses new Rust 2024
| 0.1.0 | Jan 25, 2026 |
|---|
#695 in Internationalization (i18n)
Used in cntp_i18n
41KB
706 lines
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 string trn!- 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
);
}
Dependencies
~23MB
~334K SLoC