1

I'm trying to translate "The requested qty exceeds the maximum qty allowed in shopping cart". I already have the translation in the correct translation file:

app/design/frontend/Vendor/Theme/i18n/Language.csv

with:

"The requested qty exceeds the maximum qty allowed in shopping cart","Translation"

The other translations are working (didn't test all, but the ones i need are working). The file that sets the message is:

/vendor/magento/module-inventory-sales/Model/IsProductSalableForRequestedQtyCondition/IsCorrectQtyCondition.php

I've logged all result to it with only one product in cart and it is accessed 7 times when reloading the page. Not sure it is supposed to.

Also tried to change to another phrase. Like __('January'). It displays without being translated. And in the 4 first accesses to the function it logs without translation but the last 3 it translates.

Could there be anything wrong with my setup? I'm not using the default theme. But i've run a grep to find that exact phrase only showing in the original file and when changed it changes the output. But never translates.

1 Answer 1

2

If you want to debug and understand why it doesn't work you can try to debug \Magento\Framework\Translate

See loadData method

The order to load translation

        // Load data from module translation files
        $this->_loadModuleTranslation();
        // Load translation dictionary from language packages
        $this->_loadPackTranslation();
        // Load current theme translation according to fallback
        $this->_loadThemeTranslation();
        // Loading current translation from DB
        $this->_loadDbTranslation();

Translate renderer (\Magento\Framework\Phrase\Renderer\Translate::render) uses getData for translate

First of all to be sure you have correct data in translation \Magento\Framework\Translate::getData

1
  • When i started to debug but changing the vendor/magento/framework/Translate.php, it started to work on the store view. Not sure why, because i always cleared cache and static files... Thank you for helping debug it.
    – sadlyblue
    Jul 8, 2022 at 11:59

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.