[][src]Macro fluent_templates::static_loader

macro_rules! static_loader {
    ($constructor:ident, $location:expr, $fallback:expr) => { ... };
    ($constructor:ident, $location:expr, $fallback:expr, core: $core:expr, customizer: $custom:expr) => { ... };
}

Loads Fluent data at runtime via lazy_static to produce a loader.

Usage:

use fluent_templates::*;

static_loader!(create_loader, "./locales", "en-US");

let loader = create_loader();

$constructor is the name of the constructor function for the loader, $location is the location of a folder containing individual locale folders, $fallback is the language to use for fallback strings.

Some Fluent users have a share "core.ftl" file that contains strings used by all locales, for example branding information. They also may want to define custom functions on the bundle.

This can be done with an extended invocation:

use fluent_templates::*;

static_loader!(create_loader, "./locales", "en-US", core: "./locales/core.ftl", customizer: |bundle| {
    bundle.add_function("FOOBAR", |_values, _named| todo!());
});

let loader = create_loader();