Skip to main content

Crate cntp_i18n_macros

Crate cntp_i18n_macros 

Source
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

§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 I18nSource from 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.