lhi10 Posted November 10, 2018 Share Posted November 10, 2018 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 More sharing options...
ArtcoInc Posted November 11, 2018 Share Posted November 11, 2018 @lhi10 Specifically, which page are you seeing "Please, fill out this field." that you want to change? M Link to comment Share on other sites More sharing options...
lhi10 Posted November 11, 2018 Author Share Posted November 11, 2018 Contact_us.php for example. Create_account.php when forgeting gender information, male or female, "Please, select one of these options." Link to comment Share on other sites More sharing options...
ArtcoInc Posted November 11, 2018 Share Posted November 11, 2018 It is being created by your browser, since the code uses the HTML 5 'required' attribute. M Link to comment Share on other sites More sharing options...
ArtcoInc Posted November 11, 2018 Share Posted November 11, 2018 https://stackoverflow.com/questions/10753881/changing-the-language-of-error-message-in-required-field-in-html5-contact-form HTH M Link to comment Share on other sites More sharing options...
lhi10 Posted November 11, 2018 Author Share Posted November 11, 2018 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" /> 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 More sharing options...
MrPhil Posted November 12, 2018 Share Posted November 12, 2018 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 More sharing options...
vmn Posted March 28, 2019 Share Posted March 28, 2019 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.