ZF2, I18n and dynamic locale not working anymore after update

Sam Mumm

After finally updating Apache 2.2 -> 2.4 and php 5.4 -> 5.5 translation in view is not dynamic anymore. My app is bilingual with english as fallback. The locale is set i.e. by user's profile using ::onBootstrap

class Module { public function onBootstrap($events) {

    $translator = $events->getApplication()->getServiceManager()->get(
        'translator'
    );

    $authSvc = $events->getApplication()->getServiceManager()->get('Zend\Authentication\AuthenticationService');

    $locale = $this->getLocale($authService);

    $translator->setLocale(
        \Locale::acceptFromHttp($locale)
    );

}

After updating Apache and php, translation still works but translation in view uses the default locale from the system. If I put the locale in $this->translate('MY TXT', NAMESPACE, 'en_US') it works but this is not the point. Even after debugging, I could not identify the source of the problem. It worked the way it suppose to do more than 2 years before. Any help is welcome.

Sam Mumm

Found the problem. You have to set translator with locale to the view helper:

public function onBootstrap($events)
{

    ....
    $viewRenderer = $events->getApplication()->getServiceManager()->get('ViewRenderer');

    $plugIn = $viewRenderer->plugin('translate');
    $plugIn->setTranslator($translator, __NAMESPACE__);
    ...
}

Otherwise the locale is taken from the config.global if set there (as in my case). No idea why it worked before for so long...

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

ZF2, I18n and dynamic locale not working anymore after update

From Dev

After Ubuntu update Apache2 is not working anymore

From Dev

LuisDialog not working anymore after update to 1.2.0.1

From Dev

Latex in Inkscape is not working anymore after update

From Dev

Asus Keyboard not working anymore after windows 10 update

From Dev

Yii2 i18n Validation messages not working

From Dev

ZF2 dynamic routing

From Dev

ZF2 deleteAction not working

From Dev

Translation is not working with ZF2

From Dev

ZF2 setCookie not working

From Dev

Angular Dynamic Locale not working instantly

From Dev

Force a locale in angular i18n

From Dev

How do I use ZF2 I18n currencyformatter to format bitcoin?

From Dev

Windows 10 update, Imagick php not working anymore

From Dev

Tab menu not working anymore after ajax request

From Dev

Pointer not working anymore after second iteration

From Dev

Tab menu not working anymore after ajax request

From Dev

Why did javascript stop working when I implemented ZF2 ACL?

From Dev

Why I can't define object manager in "__construct" and use it after in other methods (actions)? zf2

From Dev

ZF2 - update user profile page

From Dev

ZF2 translator is not working in controller?

From Dev

ZF2 transalation is not working in form class

From Dev

working with session on zf2 (recover container)

From Dev

ZF2 segment child route not working

From Dev

ZF2 route with prefix in not working for default

From Dev

ZF2 : Filedset validation is not working

From Dev

ZF2 2.2.6 -> 2.3.0 causes DI to try to instantiate `Zend\I18n\Translator\TranslatorInterface` instead of `Zend\I18n\Translator\Translator`

From Dev

i18n dynamic interpolation arguments

From Dev

zf2 form binding after isValid

Related Related

  1. 1

    ZF2, I18n and dynamic locale not working anymore after update

  2. 2

    After Ubuntu update Apache2 is not working anymore

  3. 3

    LuisDialog not working anymore after update to 1.2.0.1

  4. 4

    Latex in Inkscape is not working anymore after update

  5. 5

    Asus Keyboard not working anymore after windows 10 update

  6. 6

    Yii2 i18n Validation messages not working

  7. 7

    ZF2 dynamic routing

  8. 8

    ZF2 deleteAction not working

  9. 9

    Translation is not working with ZF2

  10. 10

    ZF2 setCookie not working

  11. 11

    Angular Dynamic Locale not working instantly

  12. 12

    Force a locale in angular i18n

  13. 13

    How do I use ZF2 I18n currencyformatter to format bitcoin?

  14. 14

    Windows 10 update, Imagick php not working anymore

  15. 15

    Tab menu not working anymore after ajax request

  16. 16

    Pointer not working anymore after second iteration

  17. 17

    Tab menu not working anymore after ajax request

  18. 18

    Why did javascript stop working when I implemented ZF2 ACL?

  19. 19

    Why I can't define object manager in "__construct" and use it after in other methods (actions)? zf2

  20. 20

    ZF2 - update user profile page

  21. 21

    ZF2 translator is not working in controller?

  22. 22

    ZF2 transalation is not working in form class

  23. 23

    working with session on zf2 (recover container)

  24. 24

    ZF2 segment child route not working

  25. 25

    ZF2 route with prefix in not working for default

  26. 26

    ZF2 : Filedset validation is not working

  27. 27

    ZF2 2.2.6 -> 2.3.0 causes DI to try to instantiate `Zend\I18n\Translator\TranslatorInterface` instead of `Zend\I18n\Translator\Translator`

  28. 28

    i18n dynamic interpolation arguments

  29. 29

    zf2 form binding after isValid

HotTag

Archive