|
Hasan H. Gürsoy (HHGAG) "Hasan H. Gürsoy" <[hidden email]> schrieb: >Hi there, > >is it possibly to add an alias to the > >Zend\I18n\Translator\TranslatorServiceFactory > >We're using text_domains so the calls in the template get quite long, so it >would be shorter, if the known alias > _ >for gettext could be added by default. > >Change would be: > > public function createService(ServiceLocatorInterface $serviceLocator) > { > // Configure the translator > $config = $serviceLocator->get('Configuration'); > $translator = Translator::factory($config['translator']); > > // Provide translator to the view helpers > >$serviceLocator->get('ViewHelperManager')->get('translate')->setTranslator($translator); > >$serviceLocator->get('ViewHelperManager')->get('translateplural')->setTranslator($translator); > $serviceLocator->get('ViewHelperManager')->setAlias('_', >'translate'); > > return $translator; > } > >Alternative would be add a configuration section for the ViewHelperManager. > >cmple had also asked for it: >http://zend-framework-community.634137.n4.nabble.com/ZF2-Translator-view-helper-no-longer-works-td4655480.html > > >-- >Hasan H. Gürsoy (HHGAG)
Hasan H. Gürsoy (HHGAG)
|
|
On Fri, Jul 6, 2012 at 12:38 PM, Hasan H. Gürsoy <[hidden email]>
wrote: > > > Hasan H. Gürsoy (HHGAG) > > "Hasan H. Gürsoy" <[hidden email]> schrieb: > > >Hi there, > > > >is it possibly to add an alias to the > > > >Zend\I18n\Translator\TranslatorServiceFactory > > > >We're using text_domains so the calls in the template get quite long, so > > it > >would be shorter, if the known alias > > _ > >for gettext could be added by default. Have you tested this? I thought about doing something like this, but last I checked the service manager had a canonicalizeName() method which strips things like underscores from alias and/or service names. This would mean having an alias like '_' would be impossible. :( -- Evan Coury |
|
In reply to this post by HHGAG
Hi Evan,
yes that's tested yet. Hasan H. Gürsoy (HHGAG) Evan Coury <[hidden email]> schrieb: >On Fri, Jul 6, 2012 at 12:38 PM, Hasan H. Gürsoy <[hidden email]> >wrote: >> >> >> Hasan H. Gürsoy (HHGAG) >> >> "Hasan H. Gürsoy" <[hidden email]> schrieb: >> >> >Hi there, >> > >> >is it possibly to add an alias to the >> > >> >Zend\I18n\Translator\TranslatorServiceFactory >> > >> >We're using text_domains so the calls in the template get quite long, so >> > it >> >would be shorter, if the known alias >> > _ >> >for gettext could be added by default. > >Have you tested this? I thought about doing something like this, but >last I checked the service manager had a canonicalizeName() method >which strips things like underscores from alias and/or service names. >This would mean having an alias like '_' would be impossible. :( > >-- >Evan Coury
Hasan H. Gürsoy (HHGAG)
|
|
This post has NOT been accepted by the mailing list yet.
I've added an onBootstrap listener in one of the modules, so the aliases will be added without any changes:
public function onBootstrap($e) { $e->getApplication()->getServiceManager()->get('ViewHelperManager')->setAlias('_', 'translate'); $e->getApplication()->getServiceManager()->get('ViewHelperManager')->setAlias('plural', 'translateplural'); } that works fine.
Hasan H. Gürsoy (HHGAG)
|
| Powered by Nabble | Edit this page |
