[go: up one dir, main page]

get_message

Function get_message 

Source
pub fn get_message(id: &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 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 resources

§Returns

A String containing the localized message, or the message ID if not found

§Examples

use uucore::locale::get_message;

// Get a localized greeting (from .ftl files)
let greeting = get_message("greeting");
println!("{greeting}");