更新时间:2023-11-19 22:30:16
您可以照常使用翻译资源.这对我有用:
You can use the translation resources as usual. This worked for me:
$builder->add('sex', 'choice', array(
'choices' => array(
1 => 'profile.show.sex.male',
2 => 'profile.show.sex.female',
),
'required' => false,
'label' => 'profile.show.sex.label',
'translation_domain' => 'AcmeUserBundle'
));
然后将您的翻译添加到您的 Bundle 的 Resources->translations 目录中.
And then add your translations to the Resources->translations directory of your Bundle.
来自@CptSadface 的更新:
Update from @CptSadface:
在symfony 2.7中,使用choice_label参数,你可以像这样指定翻译域:
In symfony 2.7, using the choice_label argument, you can specify the translation domain like this:
'choice_label' => 'typeName',
'choice_translation_domain' => 'messages',
不指定域,选项不会被翻译.
Without specifying the domain, options are not translated.