Struct fluent::context::MessageContext [] [src]

pub struct MessageContext<'ctx> {
    pub locales: &'ctx [&'ctx str],
    // some fields omitted
}

MessageContext is a collection of localization messages which are meant to be used together in a single view, widget or any other UI abstraction.

MessageContext Life-cycle

To create a context, call MessageContext::new with a locale list that represents the best possible fallback chain for a given locale. The simplest case is a one-locale list.

Next, call add_messages one or more times, supplying translations in the FTL syntax. The MessageContext instance is now ready to be used for localization.

To format a translation, call get_message to retrieve a fluent::context::Message structure and then format it within the context.

The result is an Option warpping a single string that should be displayed in the UI. It is recommended to treat the result as opaque from the perspective of the program and use it only to display localized messages. Do not examine it or alter in any way before displaying. This is a general good practice as far as all internationalization operations are concerned.

Locale Fallback Chain

MessageContext stores messages in a single locale, but keeps a locale fallback chain for the purpose of language negotiation with i18n formatters. For instance, if date and time formatting are not available in the first locale, MessageContext will use its locales fallback chain to negotiate a sensible fallback for date and time formatting.

Fields

Methods

impl<'ctx> MessageContext<'ctx>
[src]

[src]

[src]

[src]

[src]

[src]