fluent-templates 0.4.6

Templating for the Fluent localization framework
Documentation

fluent-templates: Templating for Fluent.

CI Status Current Version License: MIT/Apache-2.0

This crate provides you with the ability to create Fluent loaders for use in templating engines such as handlebars and tera.

Features/Template Engines

Basic handlebars example

//! Requires `--features handlebars`.
use fluent_templates::*;
use handlebars::*;
use serde_json::*;

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

fn init(handlebars: &mut Handlebars) {
    let loader = create_loader();
    let helper = FluentHelper::new(loader);
    handlebars.register_helper("fluent", Box::new(helper));
}

fn render_page(handlebars: &Handlebars) -> String {
    let data = json!({"lang": "zh-CN"});
    handlebars.render_template("{{fluent \"foo-bar\"}} baz", &data).unwrap()
}