0

Magento documentation says

How the application applies locales When the locale is changed for a store, the application searches and applies translations in the corresponding dictionaries in the following sequence:

Module translations: <module_dir>/i18n/ Translation package: app/i18n/ Theme translations: <parent_theme_dir>/i18n/ (iterated through all ancestor themes) <current_theme_dir>/i18n/ The database (translations located in this database take precedence and override translations stored in other locations.) Refer to the user guide for more information. Translation priority follows the inverse sequence, with "module translations" having the lowest priority and "database" having the highest priority.

If there are competing translations for one string, the theme dictionary translations have priority over the module translations, and child theme translations have priority over parent theme translations.

Technically lets say I have a custom module

Custom_Module; and i want to override an existing trad in Vendor_Module.

Whats would be the process to do it ?

It doesn't make sense to me to add the custom trad in the theme, as the theme shouldn't be related to any custom development of the module; also if the module is exported to an other project the theme traslation will be missing if not inside the module.

Did you already faced this kind of problematic ?

For a concrete sample this is what i'm looking to translate

vendor/amasty/rewards/view/frontend/templates/cart/rewards.phtml

<div class="pointsLeft" data-role="title">
    <?= $escaper->escapeHtml(__('You Have %1 points left', '<strong id="amreward-points-left">' . $pointsLeft . '</strong>'), ['strong']) ?>
</div>

Knowing i'm currently in fr locale and the amasty module already defines an en translation

vendor/amasty/rewards/i18n/en_US.csv

"You Have %1 points left","You Have %1 points left"

Adding the translation in my custom module didn't worked...actually I even tried to add it to my theme and it didn't worked neither. Am I missing something ?

My custom module is defined this way

<?xml version="1.0"?>


<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Custom_Module"/>
    <sequence>
        <module name="Amasty_Rewards"/>
    </sequence>
</config>
2
  • For adding traslation. what you write and where? Commented May 10 at 9:42
  • I actually ended up finding what i was missing, I have to specify the tier module in the custom module to make it work. 'a','b','Amasty_Rewards' and then it works
    – Claims
    Commented May 10 at 9:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.