macro_rules! locales {
($($code:literal),+ $(,)? $(; $option:ident)*) => { ... };
}Expand description
Declares the app’s locales as a Locales static, compiling locales/<code>.yml into the binary.
ocre::locales!("en", "fr") includes locales/en.yml and
locales/fr.yml (paths from the app root, CARGO_MANIFEST_DIR) with
include_str! and hands them to Catalog::load
on first use. The first code is the default locale, used for fallbacks. A
missing file is a compile error; a file that does not parse is logged and
listed in Catalog::errors (ocre dev and
ocre deploy refuse it earlier).
Options follow the codes after a ;: unprefixed_default serves the
default locale’s pages without a prefix (Catalog::unprefixed_default).
§Examples
ⓘ
// Not compiled here: needs `locales/en.yml` and `locales/fr.yml` next to the app's Cargo.toml.
static LOCALES: ocre::i18n::Locales = ocre::locales!("en", "fr");
// `/pricing` in English, `/fr/pricing` in French:
static LOCALES: ocre::i18n::Locales = ocre::locales!("en", "fr"; unprefixed_default);