Hey @iqoOopi,
yes it’s possible, but it’s not really gonna work with module translations because the’re only handling existing module fields. So unless you have text fields for “name” and “names” it won’t really work.
You got several other options you can try.
First of all the most easiest one that will be living in the module.html:
{% if module.some-number >= 2 %}
{% if content.domain is string_containing == "/de" %}
{% set name_plural = "Namen" %}
{% elif content.domain is string_containing == "/en" %}
{% set name_plural = "names" %}
{% else %} {# Fallback if no string_containing returns true #}
{% set name_plural = "names" %}
{% endif %}
{% else %}
{% if content.domain is string_containing == "/de" %}
{% set name_plural = "Name" %}
{% elif content.domain is string_containing == "/en" %}
{% set name_plural = "name" %}
{% else %} {# Fallback if no string_containing returns true #}
{% set name_plural = "name" %}
{% endif %}
{% endif %}
If you want a more global level of editing and keeping the module.html cleaner, you can create your own _locales folder structure somewhere in the theme
You can find an example in the @hubspot/cmsdefaultsystempages folder. Just look at something like the email-subscription-preferences.html and the system-base.html.
The key here is to have a variable like this in your theme or module
{% set template_translations = load_translations("./_locales", html_lang, "en") %}
as well as the mentioned folder-structure (you might need to change the path).
Once this is implemented, you can open the messages.json file(s) and type in something like
en/messages.json:
{
"my_name_labels":{
"singular": "name",
"plural": "names"
}
}
de/messages.json:
{
"my_name_labels":{
"singular": "Name",
"plural": "Namen"
}
}
the module.html would look like this:
{% set translations = load_translations("./_locales", html_lang, "en") %}
...
{% if module.some_number >= 2 %}
{% set label = translations.my_name_labels.plural %}
{% else %}
{% set label = translations.my_name_labels.singular %}
{% endif %}
...
<span>There are {{ module.some_number }} {{ label }} in the list </span>
best,
Anton