link-in - רשומות קוד

חפש את הקוד שלך >

Translations

היררכיה דריסה לתרגום

1. Module translations: <module_dir>/i18n/
2. Translation package: app/i18n/
3. Theme translations:
<parent_theme_dir>/i18n/ (iterated through all ancestor themes)
<current_theme_dir>/i18n/

דוגמאות

For Example:
Delete
Translated strings that originate from .xml files will not render unless
they are called with a __() method in .php files. In this
example, you would use a call similar to the following to display the
translated Delete string.
__($this->config->getData('label'))
● Strings added in Underscore templates:
To ensure that the text you add in .html Underscore templates is added
to the dictionary use the _.i18n(") Underscore function.
When a string is added to the template:
<%= _.i18n('Hello') %>
If the string contains a variable, use the variable placeholder:
<%= _.i18n('Hello %1').replace('%1', yourVariable) %>
● Strings added in .js files:
To ensure that the text you add in a .js file is added to the dictionary:
Link the mage/translate library:
define (['jquery', 'mage/translate'], function ($, $t) {…});
Use the $.mage.__(") function when adding a string:
$.mage.__(");
or
$t(");
If your string contains a variable, to add a placeholder for this variable to
the string stored in the dictionary, use the following syntax:
$.mage.__('Hello %1').replace('%1', yourVariable);
or
$t('Hello %1').replace('%1', yourVariable);