1

I installed this language pack https://github.com/splendidinternet/Magento2_German_LocalePack_de_DE. Everything worked fine.

Then I edited the following line in the magento-path\app\i18n\splendid\de_DE\de_DE.csv file:

"Add to Cart,Zum Warenkorb hinzufügen -> Add to Cart,In den Warenkorb"

When I go to category page, at first everything looks fine:

enter image description here

but when I click on the 'add to cart'(In den Warenkorb) button , the button text changes back to the translation "Zum Warenkorb hinzufügen", which was there before I edited the de_DE.csv file: enter image description here enter image description here enter image description here

When I reload the site everything looks good again: enter image description here

I think it has something to do with JS. Any hints on solving this issue ?

UPDATE: Changed Code in pub\static\frontend\<vendor>\<theme>\de_DE\Magento_Catalog\j‌​s\catalog-a‌​dd-to-cart.js:

setTimeout(function() {
                var addToCartButtonTextDefault = 'In den Warenkorb'; //changed
                console.log("test1");         addToCartButton.removeClass(self.options.addToCartButtonDisabledClass);
                addToCartButton.find('span').text(addToCartButtonTextDefault);
                console.log("test2");
                addToCartButton.attr('title', addToCartButtonTextDefault);
            }, 1000);

Now it works

1
  • You should override this js file in your custom theme. If you change the code in pub/static, the code will lose. Commented Nov 5, 2016 at 14:07

1 Answer 1

1

Take a look: vendor/magento/module-catalog/view/frontend/web/js/catalog-add-to-cart.js. As we can see, Magento uses Ajax for adding product to cart. In each state, there are some different texts:

$t('Adding...')
$t('Added')
$t('Add to Cart')

So, we need to translate for these texts.

0

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.