Hi Ludwig,
within my modules I set the textdomain like this:
---------------------------------------------------------------------
'translator' => array(
'translation_file_patterns' => array(
array(
'type' => 'phpArray',
'base_dir' => realpath(__DIR__ . '/../language'),
'pattern' => '%s.php',
'text_domain' => 'user',
),
),
),
---------------------------------------------------------------------
Within my view scripts of these modules I use this line:
---------------------------------------------------------------------
$this->plugin('translate')->setTranslatorTextDomain('user');
---------------------------------------------------------------------
So for translation texts from my module I don't need to set the
textdomain on every call of $this->translate() within my view scripts.
If I need a global text from the Application module I can always go like
this:
---------------------------------------------------------------------
$this->translate('text_for_home', 'default');
---------------------------------------------------------------------
But still the handling of the text domain is still a little awkward. If
I want to change from textdomain 'default' to another for the form view
helpers I need to change the text domain for every form view helper I use.
---------------------------------------------------------------------
public function changeViewHelper(EventInterface $e)
{
$serviceManager = $e->getApplication()->getServiceManager();
$renderer = $serviceManager->get('viewmanager')->getRenderer();
$renderer->plugin('formText')->setTranslator(
$serviceManager->get('translator'), 'user'
);
$renderer->plugin('formLabel')->setTranslator(
$serviceManager->get('translator'), 'user'
);
$renderer->plugin('formSelect')->setTranslator(
$serviceManager->get('translator'), 'user'
);
$renderer->plugin('formSubmit')->setTranslator(
$serviceManager->get('translator'), 'user'
);
}
---------------------------------------------------------------------
HTH,
Ralf
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]