Expand description
Helper for fluent language lookup.
The root data for the template must contain a lang
field
with the identifier of the current language.
Assuming a fluent language file in locales/en/main.ftl
and the lang
field is set to en
, using the contents:
ⓘ
welcome = Hello!
greeting = Hello { $name }!
block = { $var1 } { $var2 }
We can resolve the message in a template using the fluent helper like this:
ⓘ
{{fluent "welcome"}}
Pass variables using the helper hash parameters:
ⓘ
{{fluent "greeting" name="world"}}
If you need to pass multi-line variables to a message use the fluentparam
syntax
inside a block call:
ⓘ
{{#fluent "block"~}}
{{#fluentparam "var1"~}}
This is some multi-line content for
the first variable parameter named var1.
{{/fluentparam}}
{{#fluentparam "var2"}}
Which is continued in another multi-line
paragraph using the variable named var2.
{{~/fluentparam~}}
{{/fluent}}
Structs§
- Fluent
Helper - Lookup a language string in the underlying loader.
- Fluent
Param - Local helper for
{{#fluentparam}}
blocks.