Translations

With translation tag you can translate the content of a template.

You can add translations to your templates with translation tags. This will allow you to see the content in different languages.

Define translations

To make sure that the content of the template is translated in different languages, you need to define the translation by:

  1. indicating the language to which you would like to translate your text; and
  2. adding text in that particular language.

In the example below, we used a translation tag to make sure that the word expense is translated to three different languages, i.e. Dutch, French and English.

{% t= "expense" nl:"kost" fr:"les frais" en:"expense" %}

Use translations

📘

The translation depends on the language chosen in the Silverfin environment.
Let's assume that the language is French.

To use or print the translation, the word/content should be placed in brackets with the letter t in front of it.

{% t "expense" %}
Output
Les frais

Defaults

You probably want most of the texts, placeholders, etc. to be translated when switching your language in Silverfin. Consider the following code:

{% t="car" nl:"wagen" fr:"voiture" %}
{% t "car" %}

In this case, the English translation is actually not specified, only the Dutch and French translation are. However, “car" (the translation tag name) acts here as a default translation for missing languages.

You can replace this behaviour by adding a default translation in your translation tag using the keyword default:

{% t="warningtext_t" dk:"advarsel" fr:"avertissement" nl:"waarschuwing" default:"warning" %}
{% t "warningtext_t" %}
Output
warning

Variables

In some cases you might want certain parts of the translation to be dynamic (e.g. the company's place of residence, the end date of the book year).
You can use variables in translations to accommodate this. You have to use these variables using this syntax: {{ variable }} in the definition of the translation.
And then, when that translation is being used/printed in the code, you need to define the variable that was used in the definition.

{% t= "company_info" nl:"De vennootschap {{ company_name }} is gevestigd in {{ company_city }}" en:"The company {{ company_name }} is located in {{ company_city }}" %}
{% t "company_info" | company_name:company.name company_city:company.city %}
Output
The company Demo file is located in 9000 Ghent