We can config in Magento to set locale language and using function $this->__(string $test) to translate.
How about this feature but for javascript? For example, when I use validation.js and when getting some errors it will show the message with the locale language which I set.
The validation.js file is located at: src/js/prototype/prototype.js
In inside the file we will see something:
Validation.addAllThese([
['validate-select', 'Please select an option.', function(v) {
return ((v != "none") && (v != null) && (v.length != 0));
}],
['required-entry', 'This is a required field.', function(v) {
return !Validation.get('IsEmpty').test(v);
}],
['validate-number', 'Please enter a valid number in this field.', function(v) {
return Validation.get('IsEmpty').test(v) || (!isNaN(parseNumber(v)) && !/^\s+$/.test(parseNumber(v)));
}]
]
So, how could I translate the messages This is a required field.,Please select an option.?
I’m not sure if that’s what you’re asking, but the translations of th javascript messages are set in app/code/Core/Mage/Core/Helper/Js.php ->
_getTranslateData()and is called in app/design/package/ theme/template/page/html/head.phtml<?php echo $this->helper('core/js')->getTranslatorScript() ?>I’ve just need that myself, let me refrase:
in the phtml you add the strings you need to translate:
in your javascript file, use:
now you can use your csv translations files