p=t("my.key1")
p=t("myNamespace:my.key2", { count: 5, replaceMe: "something" })
// set without encoding (eg. html content)
.myClass!=t("my.key3")
!=t("my.key4", { context: "loggedIn" })
|
// setting arguments
input(type="text", placeholder!=t('my.key5'))
You can have html content written with multilines in JSON File
{
"myhtml": [
"<p>",
"my paragraph",
"</p>"
]
}
i18next will join the array with '\n'.
Hint: functions like nesting or variable replacing are still full functional.
{
"listWithHeader": {
"title": "my title",
"items": [
"item 1 ...",
"item 2 ..."
]
},
}
mixin ul(items)
- each item in items
li= item
mixin h4AndUl(entry)
h4= entry.title
ul
mixin ul(enty.items)
|
// use mixin
mixin h4AndUl(t('listWithHeader', {returnObjectTrees: true}))
By using option returnObjectTrees i18next will return an object usefull in mixins.
When using returnObjectTrees i18next won't join arrays so arrays can be used for lists.
Hint: functions like nesting or variable replacing are still full functional.
// given resources with array
{
'en-US': {
translation: {
"markdownKey": [
"### title",
"a paragraph",
"",
" // some code"
]
}
}
};
// given registered post processor
i18n.addPostProcessor("markdown", function(val, key, opts) {
return require("markdown").markdown.toHTML(val);
});
!=t("markdownKey", { postProcess: "markdown" }) // -> will output parsed markdown
Post Processor will be called after regular translation.
Hint: functions like nesting or variable replacing are still full functional.
// given resources with array
{
'en-US': {
translation: {
"jadeKey": [
"h1 title",
"p a paragraph",
"p another paragraph",
" button with nested button"
]
}
}
};
// given registered post processor
i18n.addPostProcessor("jade", function(val, key, opts) {
return require("jade").compile(val, opts)();
});
!=t("jadeKey", { postProcess: "jade" }) // -> will output parsed jade
Post Processor will be called after regular translation.
Hint: functions like nesting or variable replacing are still full functional.