Skip to main content

i18n_string

Macro i18n_string 

Source
macro_rules! i18n_string {
    ($name:ident, $($lang:expr),+) => { ... };
}
Expand description

Macro to define an internationalized string constant.

This macro creates a public constant of type I18NString that contains string variants for all supported languages. The strings are provided in the same order as the Languages enum variants.

§Syntax

matrix_gui::i18n_string!(NAME, string_for_lang0, string_for_lang1);

§Arguments

  • NAME - The identifier name for the constant
  • string_for_langN - The string for each language (must match LANG_COUNT)

§Examples

use matrix_gui::prelude::*;

// Define internationalized strings for UI elements
matrix_gui::i18n_string!(TIP_ON, "开", "ON");
matrix_gui::i18n_string!(TIP_OFF, "关", "OFF");
matrix_gui::i18n_string!(MENU_SETTINGS, "设置", "Settings");

// Use the strings
println!("{}", TIP_ON.as_str());

§Notes

  • The number of string arguments must match the number of supported languages
  • The order of strings must correspond to the Languages enum variants
  • The generated constant is public and can be used across modules