Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Added 'Strings added in Underscore templates' section to 'Translate theme strings' page #6926

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,24 @@ Translated strings that originate from `.xml` files will not render unless they
__($this->config->getData('label'))
```

## Strings added in Underscore templates {#add_strings_underscore_html}

To ensure that the text you add in `.html` Underscore templates is collected by the `i18n` tool, use the `_.i18n('')` Underscore function.

- When a string is added to the template:

```html
<%= _.i18n('Hello') %>
```

- If the string contains a variable, use the variable placeholder:

```html
<%= _.i18n('Hello %1').replace('%1', yourVariable) %>
```

In this example, the _'Hello %1'_ string is added to the dictionary when the i18n tool is run.

## Strings added in .js files {#add_strings_js}

To ensure that the text you add in a `.js` file is collected by the i18n tool and added to the dictionary:
Expand Down