Does anyone know how开发者_StackOverflow中文版 to translate form error messages in Symfony ?
At the moment I write this line in the configure()
of the form:
sfContext::getInstance()->getConfiguration()->loadHelpers(array('I18N'));
And then I overwrite all error messages with the __()
method.
Is there any way for Symfony to translate error messages without calling a helper and overwriting error messages ?
How I do it:
Add to the configure
function of the Form to following line:
$this->widgetSchema->getFormFormatter()->setTranslationCatalogue('forms');
Then create a translation file like:
\i18n\forms.nl.xml
(in your application root or the plugin root)
It's also possible to add translations for the default validators (like 'Required.', etc.)
精彩评论