Translations in result tags

Good afternoon gentlemen :-),

A question with regard to translations and result tags. I’d like to use t-tags, but from a separate file with the explicit aim of reusability.

So in the separate file (with the handle ‘Parameters’), I typed:

{% capture herwaardering %}{% t= “herwaardering” fr:“réevaluation” en:“revaluation” %}{% endcapture %}
{% result ‘herwaardering’ herwaardering %}

And in another template I typed:

{% assign herwaardering = period.reconciliations.Parameters.results.herwaardering %}
{{herwaardering}}

But this doesn’t give the desired result. What am I doing wrong here?

Thanks!

Hi Bart

You are using the equal sign wrongly in the translation tag. Adjusting it like will probably solve it:

{% t=“herwaardering” fr:“réevaluation” en:“revaluation” %}
{% capture herwaardering %}{% t “herwaardering” %}{% endcapture %}
{% result ‘herwaardering’ herwaardering %}

Kind regards
Sam

OK Sam, thanks!

Now, have a different question: is it also possible to use these translations as options in a select as follows (for example):

´´´
{% comment %}Step: Bepaal de juiste naam voor de leidinggevende(n){% endcomment %}
{% capture company_form %}{{ company.company_form | replace: ‘.’,’’ | replace: ’ ‘,’’ | upcase }}{% endcapture %}
{% case company_form %}
{% when ‘MAATSCHAP’ or ‘CVBA’ or ‘CVOA’ or ‘NV’ or ‘SE’ or ‘SCE’ or ‘VZW’ or ‘IVZW’ %}
{% assign director_type_singular_NL = ‘bestuurder’ %}
{% assign director_type_plural_NL = ‘bestuurders’ %}
{% assign director_type_singular_FR = ‘gérant1’ %}
{% assign director_type_plural_FR = ‘gérants1’ %}
{% assign director_type_singular_EN = ‘manager1’ %}
{% assign director_type_plural_EN = ‘managers1’ %}
{% else %}
{% assign director_type_singular_NL = ‘zaakvoerder’ %}
{% assign director_type_plural_NL = ‘zaakvoerders’ %}
{% assign director_type_singular_FR = ‘gérant2’ %}
{% assign director_type_plural_FR = ‘gérants2’ %}
{% assign director_type_singular_EN = ‘manager2’ %}
{% assign director_type_plural_EN = ‘managers2’ %}
{% endcase %}
{% assign str_director_type_NL = director_type_singular_NL | append: ‘|’ | append:director_type_plural_NL %}
{% assign str_director_type_FR = director_type_singular_FR | append: ‘|’ | append:director_type_plural_FR %}
{% assign str_director_type_EN = director_type_singular_EN | append: ‘|’ | append:director_type_plural_EN %}

{% capture leidinggevende_termen %}{% t= ‘bestuurder|bestuurders’ fr:‘gérant|gérants’ en:‘manager|managers’ %}{% endcapture %}
{{leidinggevende_termen}}
{% capture leidinggevende_juisteterm %}{% t ‘bestuurder|bestuurders’ fr:‘gérant|gérants’ en:‘manager|managers’ %}{% endcapture %}
menu1 => {% input custom.some.thing as:select options:leidinggevende_juisteterm %}

{% capture leidinggevende_termen2 %}{% t=str_director_type_NL fr:str_director_type_FR en:str_director_type_EN %}{% endcapture %}
{{leidinggevende_termen2}}
{% capture leidinggevende_juisteterm2 %}{% t str_director_type_NL fr:str_director_type_FR en:str_director_type_EN %}{% endcapture %}
menu2 => {% input custom.some.thing2 as:select options:leidinggevende_juisteterm2 %}

´´´

Funny thing here is that both options seem to work, but when you delete the first option, the second doesn’t work anymore! Any clues? Thanks!

Hi Bart

It think you need this:

{% t= ‘bestuurder|bestuurders’ fr:‘gérant|gérants’ en:‘manager|managers’ %}

{% capture leidinggevende_juisteterm %}{% t ‘bestuurder|bestuurders’ %}{% endcapture %}
menu1 => {% input custom.some.thing as:select options:leidinggevende_juisteterm %}

{% t=str_director_type_NL fr:str_director_type_FR en:str_director_type_EN %}
{% capture leidinggevende_juisteterm2 %}{% t str_director_type_NL %}{% endcapture %}
menu2 => {% input custom.some.thing2 as:select options:leidinggevende_juisteterm2 %}

Kind regards
Sam

Hi Sam,

OK I adapted this (see below), but I still get the same funny result: it ‘works’ like this, but when I omit the 3 lines around leidinggevende_juisteterm, menu2 doesn’t work anymore, which is really strange … any ideas? Thanks!

{% comment %}Step: Bepaal de juiste naam voor de leidinggevende(n){% endcomment %}
  {% capture company_form %}{{ company.company_form | replace: '.','' | replace: ' ','' | upcase }}{% endcapture %}
  {% case company_form %}
  {% when 'MAATSCHAP' or 'CVBA' or 'CVOA' or 'NV' or 'SE' or 'SCE' or 'VZW' or 'IVZW' %}
    {% assign director_type_singular_NL = 'bestuurder' %}
    {% assign director_type_plural_NL = 'bestuurders' %}
    {% assign director_type_singular_FR = 'gérant1' %}
    {% assign director_type_plural_FR = 'gérants1' %}
    {% assign director_type_singular_EN = 'manager1' %}
    {% assign director_type_plural_EN = 'managers1' %}
  {% else %}
    {% assign director_type_singular_NL = 'zaakvoerder' %}
    {% assign director_type_plural_NL = 'zaakvoerders' %}
    {% assign director_type_singular_FR = 'gérant2' %}
    {% assign director_type_plural_FR = 'gérants2' %}
    {% assign director_type_singular_EN = 'manager2' %}
    {% assign director_type_plural_EN = 'managers2' %}
  {% endcase %}
  {% assign str_director_type_NL = director_type_singular_NL | append: '|' | append:director_type_plural_NL %}
  {% assign str_director_type_FR = director_type_singular_FR | append: '|' | append:director_type_plural_FR %}
  {% assign str_director_type_EN = director_type_singular_EN | append: '|' | append:director_type_plural_EN %}

{% t= 'bestuurder|bestuurders' fr:'gérant|gérants' en:'manager|managers' %}
{% capture leidinggevende_juisteterm %}{% t 'bestuurder|bestuurders' %}{% endcapture %}
menu1 => {% input custom.some.thing as:select options:leidinggevende_juisteterm %}

{% t=str_director_type_NL fr:str_director_type_FR en:str_director_type_EN %}
{% capture leidinggevende_juisteterm2 %}{% t str_director_type_NL %}{% endcapture %}
menu2 => {% input custom.some.otherthing as:select options:leidinggevende_juisteterm2 %}

Hi Bart

I’m wondering if this is what you are searching for?

{% comment %}Step: Bepaal de juiste naam voor de leidinggevende(n){% endcomment %}
  {% capture company_form %}{{ company.company_form | replace: '.','' | replace: ' ','' | upcase }}{% endcapture %}
  {% case company_form %}
  {% when 'MAATSCHAP' or 'CVBA' or 'CVOA' or 'NV' or 'SE' or 'SCE' or 'VZW' or 'IVZW' %}
    {% t="options" nl:"bestuurder|bestuurders" fr:"gérant1|gérants1" en:"manager1|managers1" %}
  {% else %}
    {% t="options" nl:"bestuurder|bestuurders" fr:"gérant2|gérants2" en:"manager2|managers2" %}
  {% endcase %}

{% capture leidinggevende_juisteterm2 %}{% t "options" %}{% endcapture %}
menu => {% input custom.some.otherthing as:select options:leidinggevende_juisteterm2 %}

Kind regards
Sam

Hi Sam,

This works indeed. Great and many thanks!

Just a small remark: it’s a pity that the select becomes empty again when you change the language. So switching from Dutch to French does not automatically change the selected option from ‘bestuurder’ to ‘gérant1’.

But this is already very nice … :slight_smile:

You can solve this problem by adding the option_values attribute. As described in this post:

Once again thanks Sam,

This already works nicely, but I’d like to put the options themselves in different languages in separate variables, so they can be referenced later on with a result tag (so the strings themselves can be used in different templates). However, this doesn’t work as expected. A hint :-)?

{% assign str_NE1 = ‘bestuurder1|bestuurders1’ %}
{% assign str_NE2 = ‘bestuurder2|bestuurders2’ %}
{% assign str_FR1 = ‘gérant1|gérants1’ %}
{% assign str_FR2 = ‘gérant2|gérants2’ %}
{% assign str_EN1 = ‘manager1|managers1’ %}
{% assign str_EN2 = ‘manager2|managers2’ %}

{% capture company_form %}{{ company.company_form | replace: '.','' | replace: ' ','' | upcase }}{% endcapture %}
{% case company_form %}
{% when 'MAATSCHAP' or 'CVBA' or 'CVOA' or 'NV' or 'SE' or 'SCE' or 'VZW' or 'IVZW' %}
  {% t='options' nl:str_NE1 fr:str_FR1 en:str_EN1 %}
  {% capture leidinggevende_juisteterm %}{% t 'options' %}{% endcapture %}
  menu => {% input custom.some.thing as:select options:leidinggevende_juisteterm option_values:str_NE1 %}
{% else %}
  {% t='options' nl:str_NE2 fr:str_FR2 en:str_EN2 %}
  {% capture leidinggevende_juisteterm %}{% t 'options' %}{% endcapture %}
  menu => {% input custom.some.thing as:select options:leidinggevende_juisteterm option_values:str_NE2 %}
{% endcase %}

Hi Bart

At the moment, when using option_values, you can’t get acces to the options itself anymore. We are working on changing this in the future. However, this is a work around that should help in the meanwhile.

{% comment %}Step: Bepaal de juiste naam voor de leidinggevende(n){% endcomment %}
  {% capture company_form %}{{ company.company_form | replace: '.','' | replace: ' ','' | upcase }}{% endcapture %}
  {% case company_form %}
  {% when 'MAATSCHAP' or 'CVBA' or 'CVOA' or 'NV' or 'SE' or 'SCE' or 'VZW' or 'IVZW' %}
    {% t="options" nl:"bestuurder|bestuurders" fr:"gérant1|gérants1" en:"manager1|managers1" %}
  {% else %}
    {% t="options" nl:"bestuurder|bestuurders" fr:"gérant2|gérants2" en:"manager2|managers2" %}
  {% endcase %}

{% capture leidinggevende_juisteterm2 %}{% t "options" %}{% endcapture %}
menu => {% input custom.some.otherthing as:select options:leidinggevende_juisteterm2 option_values:"0|1" %}

{% assign options_array = leidinggevende_juisteterm2 | split:"|" %}
{% assign option_key = INT(custom.some.otherthing) %}
{% assign option_name = options_array[option_key] %}

{{option_name}}

Hopefully this helps.

Kind regards
Sam