0

I'm already having a lot of trouble translating some Magento 2 texts, but I really can't seem figure this one out. I'm trying to translate the "This is a required field." text to Dutch. I already tried editing it in my nl_NL.csv, in which other texts are being translated as well. I deployed, cleared my cache, removed my pub/static folder, all of which do not give me a result.

How do I do this?

enter image description here

2
  • You need to modify core JS file. Commented Jun 27, 2017 at 11:03
  • This text is non translatable. If your store is not multilingual you can change the text in the validation.js file. (This is not recommended though). You can override the function in rules.js in your theme at this path : app/designVendor/themename/Magento_Ui/web/js/lib/validation/‌​rules.js
    – Sejal Shah
    Commented Jun 28, 2017 at 5:51

1 Answer 1

-1

To revive an old question with one of possibly many solutions, the text can be translated through a custom JavaScript file. Within this file you can override / apply the same validation rule as the existing required-entry rule and pass it a translation.

To do this you need the following:

web/js/translations.js

require([
    'jquery',
    'mage/translate'
], function($) {
    $(document).ready(function() {
        $.validator.addMethod(
            'required-entry', function (value) {
                return (value !== '');
            }, $.mage.__('This is a required field.'));
    })
});

require.js

var config = {
    map: {
        '*': {
            'translations': 'js/translations'
        }
    }
};

i18n/nl_NL.csv

"This is a required field.", "Dit is een verplicht veld"

I hope this helps people who, like me, ran into this problem.

1
  • Hey @Mike, Can you be a bit more specific on where to put the files? Might be obvious for you, but I have no idea.
    – Rick
    Commented Jul 26, 2019 at 8:08

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.