pub fn get_message_with_args(id: &str, ftl_args: FluentArgs<'_>) -> StringExpand description
Retrieves a localized message with variable substitution.
Looks up a message with the given ID in the current locale bundle, substitutes variables from the provided arguments map, and returns the localized text. If the message ID is not found in the current locale, it will fall back to English. If the message is not found in English either, returns the message ID itself.
§Arguments
id- The message identifier in the Fluent resourcesftl_args- Key-value pairs for variable substitution in the message
§Returns
A String containing the localized message with variable substitution, or the message ID if not found
§Examples
use uucore::locale::get_message_with_args;
use fluent::FluentArgs;
// For a Fluent message like: "Hello, { $name }! You have { $count } notifications."
let mut args = FluentArgs::new();
args.set("name".to_string(), "Alice".to_string());
args.set("count".to_string(), 3);
let message = get_message_with_args("notification", args);
println!("{message}");