From 6a1715e87e8edce1abaa9a785e9d7bc64af1421f Mon Sep 17 00:00:00 2001 From: Vaha Date: Wed, 25 Mar 2020 16:25:39 +0200 Subject: [PATCH 1/2] Added 'Strings added in Underscore templates' section to the 'Translate theme strings' page --- .../translations/translate_theory.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/guides/v2.3/frontend-dev-guide/translations/translate_theory.md b/src/guides/v2.3/frontend-dev-guide/translations/translate_theory.md index 37be9a2650e..d82d1028443 100644 --- a/src/guides/v2.3/frontend-dev-guide/translations/translate_theory.md +++ b/src/guides/v2.3/frontend-dev-guide/translations/translate_theory.md @@ -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 and added to the dictionary, use the `_.i18n('')` Underscore function. + +- When only a string is added in template use the following example: + + ```html + <%= _.i18n('Hello') %> + ``` + +- When the string contains a variable, use the variable placeholder for processing string stored in the dictionary: + + ```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: From 1ac0c493b16ccfb82ba62750ac0c944a0b932df3 Mon Sep 17 00:00:00 2001 From: Donald Booth Date: Thu, 26 Mar 2020 09:18:00 -0500 Subject: [PATCH 2/2] Grammar --- .../frontend-dev-guide/translations/translate_theory.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/guides/v2.3/frontend-dev-guide/translations/translate_theory.md b/src/guides/v2.3/frontend-dev-guide/translations/translate_theory.md index d82d1028443..d1b82b9560c 100644 --- a/src/guides/v2.3/frontend-dev-guide/translations/translate_theory.md +++ b/src/guides/v2.3/frontend-dev-guide/translations/translate_theory.md @@ -102,15 +102,15 @@ __($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 and added to the dictionary, use the `_.i18n('')` Underscore function. +To ensure that the text you add in `.html` Underscore templates is collected by the `i18n` tool, use the `_.i18n('')` Underscore function. -- When only a string is added in template use the following example: +- When a string is added to the template: ```html <%= _.i18n('Hello') %> ``` -- When the string contains a variable, use the variable placeholder for processing string stored in the dictionary: +- If the string contains a variable, use the variable placeholder: ```html <%= _.i18n('Hello %1').replace('%1', yourVariable) %>