Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to translate Edge / Frozen V 2.3.4.1 Information / Error Messages


lhi10

Recommended Posts

How to translate Edge / Frozen V 2.3.4.1 Information / Error Messages

For example, "Please, fill out this field."

On previous version a file language.php contain a translation but not is Edge/Frozen edition.

Thank you.

 

 

Link to comment
Share on other sites

I am testing on two languages, english and portuguese.
When switching the language on the language boxe the error message should change.
In this case I have to change the required title to "Por favor, preencha este campo."
Is it?
 
 
 
61 down vote accepted

setCustomValidity's purpose is not just to set the validation message, it itself marks the field as invalid. It allows you to write custom validation checks which aren't natively supported.

You have two possible ways to set a custom message, an easy one that does not involve Javascript and one that does.

The easiest way is to simply use the title attribute on the input element - its content is displayed together with the standard browser message.

<input type="text" required title="Lütfen işaretli yerleri doldurunuz" />

enter image description here

If you want only your custom message to be displayed, a bit of Javascript is required. I have provided both examples for you in this fiddle.

Link to comment
Share on other sites

If this message is indeed coming from the browser itself, it will depend on the language that the browser is configured for. For most people, it will still be English, and messages will be in English. You can try some of the techniques in the referenced StackOverflow thread to add some PT text to the message. You may even be able to do some Javascript that replaces the English message with PT, but there's no guarantee that it will work on all browsers.

I'll assume that you've scanned through the English language text files to check whether this text is supplied by osCommerce. If it is, you should be able to come up with a PT language file equivalent, if it doesn't already exist.

Link to comment
Share on other sites

  • 4 months later...

I found a quite elegant way to tailor/translate the message. I added this code at the end of template.top, after footer.php:

<script>
$("input[required], select[required]").on('change', function() {
    this.setCustomValidity("");
});
$("input[required], select[required]").on('invalid', function() {
    this.setCustomValidity("<?php echo FORM_INPUT_VALUE_MISSING; ?>");
});
</script>

Define the constant in

includes/languages/english.php:
define('FORM_INPUT_VALUE_MISSING','This value is required');

and includes/languages/yourlanguage.php

e.g. in finnish.php
define('FORM_INPUT_VALUE_MISSING','Tämä on pakollinen tieto');

I've tested this in Windows 10 Chrome and Firefox, and in Android Firefox and Brave.

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...