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

Commit 97d9acf

Browse files
author
Vaha
committed
Added 'Strings added in Underscore templates' section to the 'Translate theme strings' page
1 parent c7ff807 commit 97d9acf

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/guides/v2.3/frontend-dev-guide/translations/translate_theory.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,24 @@ Translated strings that originate from `.xml` files will not render unless they
100100
__($this->config->getData('label'))
101101
```
102102

103+
## Strings added in Underscore templates {#add_strings_underscore_html}
104+
105+
To ensure that the text you add in `.html` Underscore templates is collected by the `i18n` tool and added to the dictionary, use the `_.i18n('')` Underscore function.
106+
107+
- When only a string is added in template use the following example:
108+
109+
```html
110+
<%= _.i18n('Hello') %>
111+
```
112+
113+
- When a string contains a variable, to add a placeholder for this variable to the string stored in the dictionary, use the syntax similar to the following:
114+
115+
```html
116+
<%= _.i18n('Hello %1').replace('%1', yourVariable) %>
117+
```
118+
119+
In this example, the _'Hello %1'_ string is added to the dictionary when the i18n tool is run.
120+
103121
## Strings added in .js files {#add_strings_js}
104122

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

0 commit comments

Comments
 (0)