开发者

symfony how to translate form error message

开发者 https://www.devze.com 2023-02-16 09:38 出处:网络
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:

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.)

0

精彩评论

暂无评论...
验证码 换一张
取 消