Localize text from scripts

In .po files, you can localize text added to the interface in a custom script, including in the Code widget. To do this, use the SR object and its T() method.

For example, to make a label created in the Code widget translatable, specify its text in the method as follows:

<% if (true) { %>
<br>
<%= SR.T('Client list') %>
<% } %>

The Client list string will be added to the localization .po files:

  • At the level of the component where the Code widget is placed.
  • At the configuration level.

Add translations of this string to the .po files for the locales used so that users see the text in the interface in their profile language. For more information, see Translate configuration or components.