MyCashflow themes may incorporate translation files in YAML format with text snippets that are not included in the dictionary of the online store. This article explains how you can manage translation files and use the translations in a theme.

By including texts needed by a theme in a separate translation file, you can make sure that certain texts are always available in the online store, regardless of the contents of the dictionary.

Translation files are not supported with PDF themes.

Theme translations will not overwrite dictionary translations. If the same key is included both in the theme and in the dictionary, the dictionary version will always be used.

Creating translation files

Translation files are stored in the /translations directory within the theme and named text.LANGUAGECODE.yaml. The translations in .yaml files are structured into Key: Value pairs, as shown below:

themes/shop/TEEMA/translations/text.fi.yaml
AddToBag: Lisää ostoskassiin
Bag:
    Remove: Poista ostoskassista
    Added: <p>Tuote {ProductName} lisättiin <strong>ostoskassiin</strong></p>.

You can also arrange the translation entries by namespaces, as in the example above. This is useful if there are a lot of text snippets in the theme.

It is also possible to use HTML markup and MyCashflow tags in translation entries.

The format of translation keys is restricted as follows:

  • A key cannot start with an underscore, period or digit.
  • A key cannot comprise digits only.
  • A key cannot end with an underscore or period.
  • A key cannot be empty.
  • A key cannot comprise only special characters.

Using translations in a theme

Entries are fetched from the translation file with the {Text} tag.

The translation is fetched from the file that matches the language of the store version (e.g. in an English version, the matching translation file would be text.en.yaml).

If you use Interface tags to print multilingual content that has not been translated into the language of the version in use, the content is shown in the language of the default version or the first version that has the translation available.

Below, you can see an example of printing a translation by using the {Text} tag with both the long and the short syntax:

{Text(
    code: 'AddToBag'
)}
{%AddToBag}

If you have arranged texts by namespaces, you can print individual entries by using dot notation as demonstrated below:

{Text(
    code:'Bag.Remove'
)}
{%Bag.Remove}