-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Magento 2.2.0: Translations for 'Item in Cart' missing in mini cart. #12081
Comments
@jhruehl, thank you for your report. |
The problem is that there was not js translation before I solved it temporary by overriding template and add there js translation:
you can use any name for attribute here. This solution works for me. |
@avestique Unfortunately your solution doesn't work for me. The translation also doesn't work in the checkout. The code is the same: magento/module-checkout/view/frontend/web/template/summary/cart-items.html <strong role="heading">
<translate args="maxCartItemsToDisplay" if="maxCartItemsToDisplay < getCartLineItemsCount()"/>
<translate args="'of'" if="maxCartItemsToDisplay < getCartLineItemsCount()"/>
<span data-bind="text: getCartLineItemsCount()"></span>
<translate args="'Item in Cart'" if="getCartLineItemsCount() === 1"/>
<translate args="'Items in Cart'" if="getCartLineItemsCount() > 1"/>
</strong> |
Ok. A quite easy temporary solution, to get the missing js translations actually compiled and loaded, is to create an extension, which adds a basic js file to the head via view/frontend/layout/default.xml: Then just add view/frontend/js/missing-translations.js: |
@jhruehl This doesn't work either. The js is loading, but it's not being translated. |
Actually the js-file in the extension is just a mock. We overwrite it in our default theme via design/frontend/[theme]/default/[vendor_extension]/web/js/missing-translations.js: But it could also be that you have to delete your local browser storage. One time I lost hours, because phrases in one js file weren't translated, though everything was correct. The problem at that time was my browser having cached an old js translation file and didn't reload it automatically. Opening your page in a private browser window should suffice, if the browser cache/storage is now the problem. |
Browser Cache wasn't the issue. I added the 'Item in Cart' translation manually to the |
Found core problem of this issue on site. Add
This is in minicart text which don't translate correct.
Text is translate. Even more. This content of script loading fine:
Bug is in order of script loading or some ajax request that don't return value correct. |
I have one more think. It is connected to this one. After digging in backend found this one file:
Translate does not take into account different modules. Same string and other scope are just considered to be equal. I provide example to show problem. Click to expand test code showing problem - run in php online to check result
|
I added file cart-items.html and this code. Now "Item in Cart" translating for different language works.
|
hi, any of solutions provided above doesnt work for me (M2.2.2). does anybody have working solution? thanks in advance! |
I think I have a workaround. Create the directory:
Copy cart.phtml to this directory from:
Add this code anywhere in cart.phtml: Now regenerate the static files. Side note: any phtml will do. Apparently Magento 2 scans all phtml files for __('...') and adds these to js-translation.json |
@magento-engcom-team Is there any progress on MAGETWO-83448? |
@magento-engcom-team Is there any progress on MAGETWO-83448? |
In magento 2.2 (you can probably do this in other versions as well) you can add data-bind="i18n: 'Item in Cart'" to |
The reason why some strings are not translated is because they are by default only in html files in tags like
The Magento Translation module has four different patterns it uses to detect translatable phrases. Only the translations for strings matching these patterns are translated into the js-translation.json. You can see the patterns in To fix this without needing to explicitly call for a translation on all the missing phrases, you can add the following lines into pretty much any module's di.xml:
This adds a pattern that matches the @magento-engcom-team Suggested fix for the issue is to add the above pattern (or something similar) to the relevant part of |
Best, Not fixed still the same issue. Regards, and hoping for solutions. |
@koopjesboom See my comment. Copy the lines of code and add them to any suitable module's di.xml. Then empty the pub/static/frontend folder and run
Also clean your browser cache. The minicart should be translated correctly. If not, try the above again but make sure you list the language you want to be translated to first in the third step. |
[Backport] Fix for magento#12081: missing translations in the js-translations.json
Hi @jhruehl. Thank you for your report. The fix will be available with the upcoming 2.1.15 release. |
…s-translations.json #16720
Hi @jhruehl. Thank you for your report. The fix will be available with the upcoming 2.3.0 release. |
…e js-translations.json #16892
Since updating one of our stores to Magento 2.2 the translations for 'Item in Cart' are not compiled into the var/view_processed/pub/static/frontend/{Magento-Theme}/{language code}/js-translation.json files, though the translations for 'Items in Cart' are correctly loaded.
Preconditions
Steps to reproduce
Expected result
Actual result
Details
So the problem or at least a symptom of the problem seems to be in the 'vendor/magento/module-checkout/view/frontend/web/template/minicart/content.html' template. Strangely not all 'translate'-nodes are triggering the Magento 2 Content Compiler to actually set the requested translations into the theme and language given js-translations.json files.
Though the lines
33 -
<translate args="'Item in Cart'" if="getCartLineItemsCount() === 1"/>
and
34 -
<translate args="'Items in Cart'" if="getCartLineItemsCount() > 1"/>
are almost completely identical, the translations for 'Items in Cart' are loaded, but not for 'Item in Cart'.
The text was updated successfully, but these errors were encountered: