我有这个小部件:
$this->setWidget('slug', new sfWidgetFormDoctrineChoice(array('model' => 'MyTable', 'method' => 'myMethod', 'key_method' => 'myMethod', 'add_empty' => 'Select option')));好的,我该怎么做才能翻译“选择选项”?
我不能在表单中使用__()帮助器,并将该字符串添加到我的XLIFF文件中不会自动转换它。
如果无法完成,我应该采用哪种解决方法? 我找不到任何办法,也无法在官方文件中找到任何提示。
谢谢!
I have this widget:
$this->setWidget('slug', new sfWidgetFormDoctrineChoice(array('model' => 'MyTable', 'method' => 'myMethod', 'key_method' => 'myMethod', 'add_empty' => 'Select option')));Ok, what should I do to translate the "Select option"?
I can't use the __() helper inside the form, and adding that string into my XLIFF file doesn't translate it automatically.
If it can't be done, what workaround should I implement? I can't find any way, and neither can't find any tip in the official documentation.
Thanks!
最满意答案
我想我已经解决了它:
$translated_text = $this->widgetSchema->getFormFormatter()->translate('String to translate');I think I have solved it:
$translated_text = $this->widgetSchema->getFormFormatter()->translate('String to translate');Symfony表单的i18n和add_empty(Symfony form's i18n and add_empty)我有这个小部件:
$this->setWidget('slug', new sfWidgetFormDoctrineChoice(array('model' => 'MyTable', 'method' => 'myMethod', 'key_method' => 'myMethod', 'add_empty' => 'Select option')));好的,我该怎么做才能翻译“选择选项”?
我不能在表单中使用__()帮助器,并将该字符串添加到我的XLIFF文件中不会自动转换它。
如果无法完成,我应该采用哪种解决方法? 我找不到任何办法,也无法在官方文件中找到任何提示。
谢谢!
I have this widget:
$this->setWidget('slug', new sfWidgetFormDoctrineChoice(array('model' => 'MyTable', 'method' => 'myMethod', 'key_method' => 'myMethod', 'add_empty' => 'Select option')));Ok, what should I do to translate the "Select option"?
I can't use the __() helper inside the form, and adding that string into my XLIFF file doesn't translate it automatically.
If it can't be done, what workaround should I implement? I can't find any way, and neither can't find any tip in the official documentation.
Thanks!
最满意答案
我想我已经解决了它:
$translated_text = $this->widgetSchema->getFormFormatter()->translate('String to translate');I think I have solved it:
$translated_text = $this->widgetSchema->getFormFormatter()->translate('String to translate');
发布评论