Translator in ZF2
If you're having some trouble with the translator in ZF2, take a look on the 'text_domain' option, into your "translator" configuration, in module.config.php file.
'translator' => array(
'locale' => 'pt_BR',
'translation_file_patterns' => array(
array(
'type' => 'phpArray',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.php',
'text_domain' => __NAMESPACE__
),
),
),
You need to set a different text_domain for each translate file added. ZF2 will assume default if no text_domain was set. So, you need to have a unique string to set the text_domain of your application if you are loading more than one translate file. You can solve this just with the modules _NAMESPACE_, wich is pretty unique, to set your text_domain.
It will be useful if you have a multi-language application, where there's an area with only one and default language file. Such as an administrative area.
Written by Daniel Salvagni
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#