Question

We want to translate "Please enter a valid full date", but when we edit the csv file, nothing happens.

This is the default Magento validation line in the one page checkout. When a user enters the data of birth incorrect, Magento displays the default error that is written in English.

Place the line in the Mage_Core.csv file and translate it, does not work.

How can we translate this line?

Was it helpful?

Solution

The problem comes from a core bug.

See js/varien/js.js around line 450:

...
} else if (!day || !month || !year) {
    error = 'Please enter a valid full date.';
} else {
...

See the problem? It's the period ., which does not appear in the CSV, so the translation is missed every time. The easiest solution is the edit this file directly, removing the period so that translation works again... but of course, modifying core is not best practice.

Long Solution

If you have a generic local code pool module on your system, add or edit its jstranslator.xml file, and add this:

<?xml version="1.0"?>
<jstranslator>
    <!-- js.js -->
    <validate-date-full-date translate="message" module="rootd">
        <message>Please enter a valid full date.</message>
    </validate-date-full-date>
    <!-- end js.js -->
</jstranslator>

Here we should effectively overwrite the entry for this message that was originally defined in app/code/core/Mage/Core/etc/jstranslator.xml, and include the period which core code expects according to js/varien/js.js. Then, you can add an entry to your CSV:

"Please enter a valid date.","Your translation here"

OTHER TIPS

If Magento caching is enabled, try again after refreshing Translations cache from System >> Cache Management.

My answer was I had to enter a valid date that I received the product So I’m in Indiana USA I entered 4/21/2020 and it wouldn’t except it so I’ll try April 21’20 at 12:39pm not sure yet

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top