Reputation: 18064
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!
Upvotes: 3
Views: 941
Reputation: 476
You can use helper inside form, try this:
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')));
...
}
Upvotes: 0
Reputation: 18064
I think I have solved it:
$translated_text = $this->widgetSchema->getFormFormatter()->translate('String to translate');
Upvotes: 5