diff --git a/src/i18n.rs b/src/i18n.rs index 2cf5f427..96c699f4 100644 --- a/src/i18n.rs +++ b/src/i18n.rs @@ -53,11 +53,11 @@ impl Fairing for I18n { } } -fn tera_gettext(ctx: HashMap) -> Result { - let trans = gettext(ctx.get("t").unwrap().as_str().unwrap()); +fn tera_gettext(msg: serde_json::Value, ctx: HashMap) -> Result { + let trans = gettext(msg.as_str().unwrap()); Ok(serde_json::Value::String(Tera::one_off(trans.as_ref(), &ctx, false).unwrap_or(String::from("")))) } pub fn tera(t: &mut Tera) { - t.register_global_function("_", Box::new(tera_gettext)) + t.register_filter("_", tera_gettext) } diff --git a/templates/instance/index.html.tera b/templates/instance/index.html.tera index 28cbe06a..b859fc8c 100644 --- a/templates/instance/index.html.tera +++ b/templates/instance/index.html.tera @@ -6,7 +6,7 @@ {% endblock title %} {% block content %} -

{{ _(t="Welcome on {{ instance_name }}", instance_name=instance.name) }}

+

{{ "Welcome on {{ instance_name }}" | _(instance_name=instance.name) }}

Latest articles