2

I can't translate the string 'All' from the subcategory on mobile menu. The file where the string appears is menu.js located on public/lib/web/mage/

And it looks like this:

.text($.mage.__('All ') + category);

So only the string 'All' needs to be translated, it doesn't require to put something like 'All %1', 'translatedAll %1' in my language file. The translations I made looks like this:

"All ", "translatedAll "

Also I tried to put the location for the translation, like this:

"All ","translatedAll ",lib,lib/web/mage/menu.js

But it doesn't work. I also tried to translate directly in the en_US.csv file from public/lib/web/i18n/. Not working either

How can I translate this?

3
  • It's seems specific theme dependent... Have you try to change the menu.js file?
    – Nolwennig
    Nov 15, 2017 at 14:54
  • Translations actually have their own cache, so double check that you aren't getting tripped up there: magento cache:clean translate or System>Cache Management.
    – nshiff
    Nov 15, 2017 at 19:21
  • This is not the problem. Nov 16, 2017 at 11:08

1 Answer 1

0

Answer for Magento 2.3.x and 2.4.x :

Responsible file for this html is lib/web/mage/menu.js You can see translatable text is "All %1".

In your app/design/[Vendor]/[ThemeName]/i18n/en_US.csv (change .csv file name following translation you need), add this line :

"All %1", "Yourtranslation %1"

Then run php bin/mangento c:f to flush cache.

Sometimes flushing the cache is not enough for js translation, you will need to delete the file js-translation.json located in pub/static/frontend/[Vendor]/[ThemeName]/[local]/js-translation.json

It will be regenerated when loading page.

Hope this help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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