CASE: variables in translation-tags

You could have a case where you’d want to use different languages, and in your sentence you use some variables.

For instance:


{% assign name = "Michael Jordan" %}
{% assign start_mandat = company.custom.mandat.start %}


The mandat of {{ name }} has started on {{ start_mandat }}.  

which gives this as output:
00

If you want to translate this to other languages, you’ll need to use the translation-tag, like this:


{% t= "The mandat of" nl:"Het mandaat van" %}
{% t= "has started on" nl:"is begonnen op" %}

{% assign name = "Michael Jordan" %}
{% assign start_mandat = 'today' | date: '%d/%m/%y' %}


{% t "The mandat of" %} {{ name }} {% t "has started on" %} {{ start_mandat }}. 

So we take the words or sentences without the variable in a translation tag, which can become impractical.

:bulb:

From now on however, you can take variables within a translation-tag, like this:


{% t= "The mandat of {{ name }} has started on {{ start_mandat }}" nl:"Het mandaat van {{ name }} is begonnen op {{ start_mandat }}" %}

{% t "The mandat of {{ name }} has started on {{ start_mandat }}" name:"Michael Jordan" start_mandat:company.custom.mandat.start %}  

Less code now, but you’ll have to define your variables within the translation-tag as well.

1 Like