Skip to main content

lookup_static

Function lookup_static 

Source
pub fn lookup_static<'a, B: BundleCollection + ?Sized, C: CacheStore + ?Sized>(
    bundles: &'a B,
    cache: &C,
    key: &'a str,
) -> Cow<'a, str>
Expand description

Retrieves a localized message without arguments.

This function attempts to return a Cow::Borrowed referencing static binary data whenever possible to avoid allocation.

§Resolution Order

  1. Current Language: Checks if the key exists in the current language.
  2. Fallback Language: If missing, checks the FALLBACK_LANG_KEY (en-US).
  3. Missing Key: Returns the key itself wrapped in Cow::Borrowed.

§Arguments

  • bundles - The collection of Fluent bundles (usually crate::LOCALES).
  • cache - The static cache map (usually crate::CACHE).
  • key - The message ID to look up.