pub type Locales = LazyLock<Catalog>;Expand description
The app’s translations: a Catalog parsed on first use, declared once as a static.
Build it with locales!, which compiles the files into
the binary; the first access in a Worker instance parses them, once, and
later accesses reuse the parsed tables.
§Examples
ⓘ
// Not compiled here: `locales!` includes `locales/*.yml` from the app's root.
static LOCALES: ocre::i18n::Locales = ocre::locales!("en", "fr");Without files, e.g. in tests:
use std::sync::LazyLock;
static LOCALES: ocre::i18n::Locales =
LazyLock::new(|| ocre::i18n::Catalog::load(&[("en", "en:\n title: Posts\n")]));
assert_eq!(LOCALES.locale("en").t("title").to_string(), "Posts");Aliased Type§
pub struct Locales { /* private fields */ }