magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Extension/Ups Helper Class ignoring translation files in other locations

Open nobuttsalex opened this issue 10 years ago • 3 comments

Steps to reproduce I am trying to translate the name of a UPS shipping option, in this case "UPS Standard". The names of the shipping options are defined in app\code\Magento\Ups\Helper\Config.php. My locale is set to en_GB therefore if I create the file app\code\Magento\Ups\i18n\en_GB.csv with the contents "UPS Standard","Next-Day" the shipping option is translated as it should. However, this needs to be translated outside of app\code\Magento\Ups as these are system files. If I then copy the same translation file to a better location e.g. app\design\frontend\MyThemes\MyTheme\i18n\en_GB.csv the translation is ignored in the Ups Helper Class.

Expected result "UPS Standard" to be translated to "Next-Day" on cart/checkout pages

Actual result Translation is ignored and stays as "UPS Standard"

nobuttsalex avatar Apr 06 '16 15:04 nobuttsalex

Update: It does work by adding a translation file to app\code\MyExtensions\MyExtension\i18n\en_GB.csv so maybe theme translations only change templates and extension translations change all files such as Helper classes.

nobuttsalex avatar Apr 07 '16 09:04 nobuttsalex

Hi @nobuttsalex

We've created MAGETWO-52254 internal ticket regarding this issue

alena-marchenko avatar Apr 25 '16 07:04 alena-marchenko

The reason translations are not applied to api requests is because api requests operate in their own area which is neither frontend or adminhtml. Having their own area means that they do not have a theme attached. Furthermore, webapi translations could be translated using language packs and/or from inside the modules. It wouldn't make sense to have translations applied to webapi from a specific theme because the purpose of having translations inside the themes is for phrases that are defined in the theme files.

hshar7 avatar Apr 29 '16 17:04 hshar7