zend framework 2 get locale from view PhpRenderer
Asked Answered
B

2

0

How I can obtain traslator locale in my view?

I want to do it starting from the variable $this (the PhpRenderer of the view). i.e. I don't want use onBootstrap nor ActionController because I don't care to have a view variables.

Thank you!

Berget answered 25/10, 2012 at 19:7 Comment(1)
If you don't care for certain stuff, please provide your use-case, too. Since that may influence the answer. tbp: what exactly do you want to do?Soakage
D
3

You should try:

<?php echo \Locale::getDefault(); ?>

Many of the I18n classes make reference to PHP's Locale class (http://www.php.net/locale) - so in my opinion that would be a good starting point.

Depreciatory answered 25/10, 2012 at 22:36 Comment(0)
G
0
<?php echo $this->plugin('translate')->getTranslator()->getLocale(); ?>

See: Get local value in layout or view in Zend Framework 2

Govern answered 28/10, 2015 at 6:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.