zend-translate

Translate variables with POEdit/xgettext

亡梦爱人 提交于 2020-02-05 08:33:33
问题 I am using PHP , Zend Framework and Zend_Translate (gettext adapter). To edit translations I use POEdit which utilizes xgettext to fetch strings to be translated. POEdit (xgettext) will search for keywords to find strings to translate. So, if searching for the keyword translate , POEdit will have no problem finding the 'Text to translate' string when the text is passed to the translate function directly like: echo translate('Text to translate'); But, in ofther cases strings will be passed to

Translating route segments with ZF's gettext adapter

限于喜欢 提交于 2020-01-04 14:11:08
问题 I want to try out the route translations in Zend Framework, but I'm using the gettext adapter and the most tutorials have PHP translate adapter, so I'm having problems to make it work. In the main Bootstrap.php I have the method in which I set the routes: $front = Zend_Controller_Front::getInstance(); $router = $front->getRouter(); $translator = Zend_Registry::get('Zend_Translate'); Zend_Controller_Router_Route::setDefaultTranslator($translator); $routerRoute = new Zend_Controller_Router

Translating route segments with ZF's gettext adapter

﹥>﹥吖頭↗ 提交于 2020-01-04 14:10:02
问题 I want to try out the route translations in Zend Framework, but I'm using the gettext adapter and the most tutorials have PHP translate adapter, so I'm having problems to make it work. In the main Bootstrap.php I have the method in which I set the routes: $front = Zend_Controller_Front::getInstance(); $router = $front->getRouter(); $translator = Zend_Registry::get('Zend_Translate'); Zend_Controller_Router_Route::setDefaultTranslator($translator); $routerRoute = new Zend_Controller_Router

Zend framework 2 : How to set locale globaly?

帅比萌擦擦* 提交于 2020-01-02 01:55:31
问题 I have to change the locale dynamically depending which language the user wants. I can set the locale in the Application/Module.php like this : public function onBootstrap(MvcEvent $e) { $translator = $e->getApplication()->getServiceManager()->get('translator'); $translator->setLocale('hu_HU'); } But, how can I do this in the controller, if I want to change languages ? I tried this, but after this I can change the locale only for this one request and not global. $translator = $this-

zend framework 2 get locale from view PhpRenderer

浪子不回头ぞ 提交于 2019-12-25 01:01:13
问题 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! 回答1: 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. 回答2: <?php echo $this->plugin('translate')-

Zend framework not able to route the translated child routes

筅森魡賤 提交于 2019-12-23 10:12:03
问题 I am new to Zend framework 3 and was trying to translate the routes and i have partially succeeded.I am able to translate the main route and redirect it to the required location but for child routes the translation works but the redirection doesn't. can you please help me, my code is below. module.config.php 'router' => [ 'router_class' => TranslatorAwareTreeRouteStack::class, 'routes' => [ 'setting' => [ 'type' => Segment::class, 'options' => [ 'route' => '/{locale}/{setting}', 'defaults' =>

Zend Framework 2 - Translate Standard Form Validation and Error messages

让人想犯罪 __ 提交于 2019-12-18 17:28:31
问题 I'm writing a complete German application and therefore need to set basically everything to German. My question: What is the best and easiest way to set for example the form validation to German? I found this page but couldn't figure out how to get this code working: Zend_Validate_Abstract::setDefaultTranslator($translate); Could anyone give me some advice how to use this? Edit: Thanks to @Gordon I put the following into my Application/Module.php: use Zend\I18n\Translator\Translator; use Zend

How can I convert a Zend localization/translation array to gettext?

為{幸葍}努か 提交于 2019-12-14 02:46:03
问题 My multi-lingual site already successfully uses the "array" method of Zend translations. I want to convert from that method to the "gettext" method because I've read that gettext is superior. I've tried using http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/php2po.html but can't get it to work. I think it's not meant to handle Zend arrays as the input. My Zend file (which works) looks like this: <?php return array( 'choose your favorite stores' => 'Choose your %1

How can I find out which Language was used by Translator in ZF2?

a 夏天 提交于 2019-12-13 04:47:17
问题 In my ZF2 application I want to retrieve the language that was used to translate the page. I use the ZendSkeletonApplication as basis. In the Module.php I set the Locale like this: public function onBootstrap($e){ $translator = $e->getApplication()->getServiceManager()->get('translator'); $translator->setLocale( Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) ->setFallbackLocale('en_US'); } I can retrieve the locale and the fallbackLocale from the Zend\I18n\Translator\Translator ,

Zend translate URL and language switcher

安稳与你 提交于 2019-12-13 04:42:48
问题 I have managed to make my URL i18n compliant using Zend_Controller_Router . Ie: en/user/login becomes fr/utilisateur/connexion and both URLs go to the same controller / action . The problem I am facing is the following I have a language switcher that is displayed as follow : Français English Italiano etc. The currently active language doesn't have an anchor tag, but all others do. For the languages that have an anchor on them I am building the URL and I want them to be translated in their