Skip to content

Javascript String Internationalisation not working #2941

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

Closed
thomvanderboon opened this issue Jan 9, 2016 · 3 comments
Closed

Javascript String Internationalisation not working #2941

thomvanderboon opened this issue Jan 9, 2016 · 3 comments
Assignees

Comments

@thomvanderboon
Copy link

I've noted that there is something not working with the translation of javascript strings.

I've set up a demo site: http://mage2-test.vanderboon.net

If you add a product to the cart. Click the button "Toevoegen aan Winkelwagen" (Add to Cart in Dutch), after you click, you will see "Adding..." and "Added" And "Add to Cart".

The three last messages are not translated.

In the catalog-add-to-cart.js the following strings are defined:

        addToCartButtonTextWhileAdding: $t('Adding...'),
        addToCartButtonTextAdded: $t('Added'),
        addToCartButtonTextDefault: $t('Add to Cart')

But for some reason the translated texts are not displayed in JavaScript. I notice more JavaScript strings which are not translated correctly

I 've added the following lines to my nl_NL.csv

Adding...,Toevoegen...,module,Magento_Catalog
Added,Toegevoegd,module,Magento_Catalog
"Add to Cart","Toevoegen aan Winkelwagen",module,Magento_Catalog


My language file is here: http://www.vanderboon.net/magento-translation/dutch.csv (> 95% complete)

The language file was installed the following way: http://www.vanderboon.net/wiki/Install_Test_Magento_2_Translation

@chicgeek
Copy link
Contributor

I have also reported this in issue #2056.

As a workaround for this specific instance until a fix is released, you can specify your options in the template that calls catalogAddToCart and rely on PHP translation instead of JS translation. For example in list.phtml:

<script type="text/x-magento-init">
{
    "[data-role=tocart-form], .form.map.checkout": {
        "catalogAddToCart": {
            "addToCartButtonTextDefault": "<?php echo __('Add to Cart'); ?>",
            "addToCartButtonTextWhileAdding": "<?php echo __('Adding...'); ?>",
            "addToCartButtonTextAdded": "<?php echo __('Added'); ?>"
        }
    }
}
</script>

@okorshenko okorshenko added the PS label Mar 8, 2016
@okorshenko okorshenko self-assigned this Mar 8, 2016
@11mb
Copy link

11mb commented May 2, 2016

I have the same problem. Also the texts in the checkout popover and the javascript texts of some external modules won't translate. This is in version 2.0.4.

@hshar7
Copy link
Contributor

hshar7 commented May 13, 2016

Hey guys this issue was fixed not too long ago in scope of: 690cae8

@hshar7 hshar7 closed this as completed May 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants