From 3afc57a6b524190d9f309ec6c846843e49f67575 Mon Sep 17 00:00:00 2001 From: Sathish Date: Wed, 21 Oct 2020 16:50:56 +0530 Subject: [PATCH 1/4] Updated another way of string translation in js --- .../translations/translate_theory.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 c02e394d8c7..7f6f4781737 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 @@ -125,7 +125,7 @@ To ensure that the text you add in a `.js` file is collected by the i18n tool an 1. Link the `mage/translate` library: ```javascript - define (['jquery', 'mage/translate'], function ($) {...}); + define (['jquery', 'mage/translate'], function ($, $t) {...}); ``` 1. Use the `$.mage.__('')` function when adding a string: @@ -133,12 +133,20 @@ To ensure that the text you add in a `.js` file is collected by the i18n tool an ```javascript $.mage.__(''); ``` + (or) + ```javascript + $t(''); + ``` If your 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: ```javascript $.mage.__('Hello %1').replace('%1', yourVariable); ``` + (or) + ```javascript + $t('Hello %1').replace('%1', yourVariable); + ``` In this example, the `'Hello %1'` string is added to the dictionary when the i18n tool is run. From ea528a33b05b436ea1886b0e20abdc333f7ef7ef Mon Sep 17 00:00:00 2001 From: Sathish Date: Wed, 21 Oct 2020 16:50:56 +0530 Subject: [PATCH 2/4] Updated another way of string translation in js --- .../translations/translate_theory.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 c02e394d8c7..cda055d32e1 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 @@ -125,7 +125,7 @@ To ensure that the text you add in a `.js` file is collected by the i18n tool an 1. Link the `mage/translate` library: ```javascript - define (['jquery', 'mage/translate'], function ($) {...}); + define (['jquery', 'mage/translate'], function ($, $t) {...}); ``` 1. Use the `$.mage.__('')` function when adding a string: @@ -133,12 +133,20 @@ To ensure that the text you add in a `.js` file is collected by the i18n tool an ```javascript $.mage.__(''); ``` + or + ```javascript + $t(''); + ``` If your 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: ```javascript $.mage.__('Hello %1').replace('%1', yourVariable); ``` + or + ```javascript + $t('Hello %1').replace('%1', yourVariable); + ``` In this example, the `'Hello %1'` string is added to the dictionary when the i18n tool is run. From ccc5537c5ce551f5738d1e2dbb085f2896d40f47 Mon Sep 17 00:00:00 2001 From: Donald Booth Date: Mon, 2 Nov 2020 14:58:21 -0500 Subject: [PATCH 3/4] Added proper spacing --- .../frontend-dev-guide/translations/translate_theory.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 cda055d32e1..e50db2dbbb3 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 @@ -133,17 +133,21 @@ To ensure that the text you add in a `.js` file is collected by the i18n tool an ```javascript $.mage.__(''); ``` + or + ```javascript $t(''); ``` - If your 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: + If your string contains a variable, to add a placeholder for this variable to the string stored in the dictionary, use the following syntax: ```javascript $.mage.__('Hello %1').replace('%1', yourVariable); ``` + or + ```javascript $t('Hello %1').replace('%1', yourVariable); ``` From 713aba8c5cb8b786026ba67b3debf88cc040b950 Mon Sep 17 00:00:00 2001 From: Donald Booth Date: Fri, 6 Nov 2020 08:37:53 -0500 Subject: [PATCH 4/4] Linting --- .../frontend-dev-guide/translations/translate_theory.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 e50db2dbbb3..ac4f51a20df 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 @@ -133,9 +133,9 @@ To ensure that the text you add in a `.js` file is collected by the i18n tool an ```javascript $.mage.__(''); ``` - + or - + ```javascript $t(''); ``` @@ -145,9 +145,9 @@ To ensure that the text you add in a `.js` file is collected by the i18n tool an ```javascript $.mage.__('Hello %1').replace('%1', yourVariable); ``` - + or - + ```javascript $t('Hello %1').replace('%1', yourVariable); ```