0

I want to transalte several strings in the checkout, however, putting them in a CSV or turining on inline translation doesn't seem to rename them.

enter image description here

How can I rename Shipping, Review & Payments and Please enter a valid email address (Ex: johndoe@domain.com).?

  • What language pack are you using? Do you find "Shipping" and "Review & Payments" inside your language pack? On Magento 2.1.3 for JS message error translation I'm using validation.js from develop branch, I've develop an extension to extend Magento core for this. – Jonathan Ribas Feb 28 '17 at 13:00
  • As written in der question itself it does not matter if I put the content into the CSV or not, it simply does not translate. As for the validation.js, could you elaborate here? Sounds useful! – Max Feb 28 '17 at 13:09
1

In order to override JS validation class you need to create a new module

app/code/local/Vendor/OverrideCore/etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_OverrideCore" setup_version="0.1.0" />
</config>

app/code/local/Vendor/OverrideCore/composer.json

{
  "name": "vendor/overridecore",
  "description": "Override Core for Magento 2",
  "require": {
    "php": "~5.5.0|~5.6.0|~7.0.0"
  },
  "type": "magento2-module",
  "version": "0.1.0",
  "authors": [
    {
      "name": "Vendor",
    }
  ],
  "autoload": {
    "files": [
      "registration.php"
    ],
    "psr-4": {
      "Vendor\\OverrideCore\\": ""
    }
  }
}

app/code/local/Vendor/OverrideCore/registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Vendor_OverrideCore',
    __DIR__
);

Inside your new module create those folders:

app/code/local/Vendor/OverrideCore/view/frontend/web/ app/code/local/Vendor/OverrideCore/view/frontend/web/js/

Create this file app/code/local/Vendor/OverrideCore/view/frontend/web/requirejs-config.js:

/*jshint browser:true jquery:true*/
/*global alert*/
var config = {
    map: {
        '*': {
            'mage/validation': 'Vendor_OverrideCore/js/validation',
            'mage/validation/validation': 'Vendor_OverrideCore/js/validation',
            passwordStrengthIndicator : 'Vendor_OverrideCore/js/password-strength-indicator'
        }
    }
};

Create this file app/code/local/Vendor/OverrideCore/view/frontend/web/js/password-strength-indicator.js:

https://github.com/magento/magento2/blob/develop/app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js

Create this file app/code/local/Vendor/OverrideCore/view/frontend/web/js/validation.js:

https://github.com/magento/magento2/blob/develop/lib/web/mage/validation/validation.js

Enable module

php bin/magento module:enable Vendor_OverrideCore

  • How'd you replace the vendor/magento/module-checkout/view/frontend/web/js/view/shipping.js-file? Could you make an example, please? – Max Feb 28 '17 at 14:04
  • 1
    var config = { map: { '*': { 'Magento_Checkout/js/view/shipping': 'Vendor_OverrideCore/js/view/shipping' } } }; – Jonathan Ribas Feb 28 '17 at 14:38
  • Your solution breaks the checkout anyhow in Magento 2.0.9. :( – Max Feb 28 '17 at 15:43
  • Sorry as I told you this solution is working on 2.1.3 CE. Do a diff between this files and your version, you will see that's a lot about translate method calls missing. – Jonathan Ribas Feb 28 '17 at 15:45
  • I thank you anyway for your effort to help me! :-* Appreciated, even if not functional... Those Mage devs... u.u – Max Feb 28 '17 at 15:47
0

There is no need to create a module, maybe you can translate this files in your theme folder.

To solve this Magento bug, i copy the file lib/web/mage/validation.js to my theme and translated it there.

So, the translated file is in: app/design/frontend/vendor/theme/web/mage/validation.js

Make sure to: rm -rf var/view_preprocessed/* and rm -rf pub/static/* and refresh !

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.