-
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
Translation not working in catalog-add-to-cart.js #14024
Comments
@krisztian-fekete, thank you for your report. |
A bit of follow-up: it seems the issue is caused by This was allegedly fixed in 2.2.2 so I'll try to upgrade and see if that solves it. |
I am working on this at #dmcdindia |
This should be related to another issue: #3771 |
@magento give me 2.4-develop instance |
Hi @drabikowy. Thank you for your request. I'm working on Magento 2.4-develop instance for you |
Hi @drabikowy, here is your Magento instance. |
Hi @krzksz. Thank you for working on this issue.
|
Preconditions
Magento v2.2.1 Enterprise Edition
Steps to reproduce
I wanted to change the default "Add to Cart" text of the add to cart button to "Add to Basket", so I created a translation CSV file in my theme:
app/design/frontend/MyTheme/default/i18n/en_GB.csv
with the following content:
Which works fine.
However, if I click on "Add to Basket",
catalog-add-to-cart.js
changes it back to "Add to Cart".I checked this file and it seems to disable the button (
disableAddToCartButton
) while the item is added to the basket (changing the text to "Adding..."), then it callsenableAddToCartButton
to re-enable it:Since there is no
addToCartButtonTextDefault
specified inoptions
, it falls back to$t('Add to Cart')
.$t
is supposed to callmage/translate
to translate the string to the one I specified in the translation file, judging from this bit:But it does not — the button text is changed to "Add to Cart"
Workaround
As a workaround, I created a
mixin
to set theaddToCartButtonTextDefault
option to 'Add to Basket', but I'd rather havemage/translate
translate the string in the js:app/design/frontend/MyTheme/default/Magento_Catalog/web/js/catalog-add-to-cart-mixin.js
with the following content:app/design/frontend/MyTheme/default/Magento_Catalog/requirejs-config.js
with the following content:The text was updated successfully, but these errors were encountered: