[−][src]Macro fluent_templates::static_loader
Loads Fluent data at runtime via lazy_static
to produce a loader.
Usage:
use fluent_templates::*; static_loader!(create_loader, "./tests/locales/", "en-US"); fn init() { let loader = create_loader(); let helper = FluentHelper::new(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, "./tests/locales/", "en-US", core: "./tests/core.ftl", customizer: |bundle| {bundle.add_function("FOOBAR", |_values, _named| {unimplemented!()}); }); fn init() { let loader = create_loader(); let helper = FluentHelper::new(loader); }
The constructor function is cheap to call multiple times since all the heavy duty stuff is stored in shared statics.