Automatically translating text in custom code

If your website is available in multiple languages, you can mark text inside custom code for automatic translation. During publishing, the marked text is translated to match the language of each page, making it easy to maintain multilingual custom code without creating separate versions for every language.

Translating text in custom code


Here’s how to do this: 

  1. Open a multilingual page in the editor.
  2. Go to Website Settings and switch to the Custom Code tab.
  3. Add a new code snippet.
  4. Wrap any text you want translated using the translation tag shown in the hint below the code editor.

For example:

<h2>{% t "Our services" %}</h2>

  1. Click Submit to save your changes.
  2. Publish your website.

During publishing, the wrapped text is automatically translated for each language version of your website.

Where you can use it

Automatic translation is supported in:

  • Website Settings → Custom Code
  • Page Settings → Custom Code
  • HTML blocks
  • Custom widgets

Note:

  • Only text wrapped with the translation tag is translated automatically.
  • Text that isn't wrapped remains the same in every language.
  • If the translation service is temporarily unavailable during publishing, your website will still be published using the original text. A notification will let you know if any custom code couldn't be translated, and you can simply publish the website again to retry the translation.
Was this article helpful?
0 out of 0 found this helpful