开发者

symfony how to translate form error message

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜