1

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?

  • Please be more specific, using examples of code that you've tried first. Is this part of a specific module? If so, please post the module configuration and paths to your translation file(s). – Rick Buczynski Dec 2 '14 at 14:58
  • @vBuck I edit my question. It is the default Magento validation error that is displayed. – Henk Z Dec 2 '14 at 15:12
  • Try to put it in translate.csv in your theme. Are you in developer mode? – Fabian Blechschmidt Dec 2 '14 at 16:41
2

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"
0

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

  • Thanks for your reply, but we disabled the cache. So it is not a cache issue. – Henk Z Dec 2 '14 at 15:18

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.