[go: up one dir, main page]

Function get_message

Source
pub fn get_message(id: &str, default: &str) -> String
Expand description

Retrieves a localized message by its identifier.

Looks up a message with the given ID in the current locale bundle and returns the localized text. If the message ID is not found, returns the provided default text.

§Arguments

  • id - The message identifier in the Fluent resources
  • default - Default text to use if the message ID isn’t found

§Returns

A String containing either the localized message or the default text

§Examples

use uucore::locale::get_message;

// Get a localized greeting or fall back to English
let greeting = get_message("greeting", "Hello, World!");
println!("{}", greeting);