Symfony1 Symfony表格';s i18n并将其添加为空

Symfony1 Symfony表格';s i18n并将其添加为空,symfony1,Symfony1,我有一个小部件: $this->setWidget('slug', new sfWidgetFormDoctrineChoice(array('model' => 'MyTable', 'method' => 'myMethod', 'key_method' => 'myMethod', 'add_empty' => 'Select option'))); 好的,我应该如何翻译“选择选项” 我无法在表单中使用_;()帮助程序并添加该字符串 到我的XLIFF文

我有一个小部件:

$this->setWidget('slug', new sfWidgetFormDoctrineChoice(array('model' 
=> 'MyTable', 'method' => 'myMethod', 'key_method' => 'myMethod', 
'add_empty' => 'Select option'))); 
好的,我应该如何翻译“选择选项”

我无法在表单中使用_;()帮助程序并添加该字符串 到我的XLIFF文件不会自动转换它

如果无法完成,我应该实施哪些变通方法?我找不到 不管怎么说,在官方文件中都找不到任何提示


谢谢

我想我已经解决了:

$translated_text = $this->widgetSchema->getFormFormatter()->translate('String to translate');

您可以在窗体内使用帮助器,请尝试以下操作:

public function setup()
{
  sfContext::getInstance()->getConfiguration()->loadHelpers(array('I18n'));

  $this->setWidget('slug', new sfWidgetFormDoctrineChoice(array('model' 
    => 'MyTable', 'method' => 'myMethod', 'key_method' => 'myMethod', 
    'add_empty' => __('Select option'))); 
  ...
}

这是一个非常丑陋的解决方案,在测试中不起作用。阅读