macro_rules! translate {
($id:expr) => { ... };
($id:expr, $($key:expr => $value:expr),+ $(,)?) => { ... };
}Expand description
Macro for retrieving localized messages with optional arguments.
This macro provides a unified interface for both simple message retrieval
and message retrieval with variable substitution. It accepts a message ID
and optionally key-value pairs using the "key" => value syntax.
§Arguments
$id- The message identifier string- Optional key-value pairs in the format
"key" => value
§Examples
use uucore::translate;
use fluent::FluentArgs;
// Simple message without arguments
let greeting = translate!("greeting");
// Message with one argument
let welcome = translate!("welcome", "name" => "Alice");
// Message with multiple arguments
let username = "user name";
let item_count = 2;
let notification = translate!(
"user-stats",
"name" => username,
"count" => item_count,
"status" => "active"
);