Zend Translation and View Scripts -


form labels , error messages translated automatically. strings in view scripts not. have use $this->translate("text transfer"); in each , every phtml files.i don't want use $this->translate("text transfer"); method.how can automatically translate view scripts in case of forms.my code

protected function _inittranslation() {      $langnamespace = new zend_session_namespace('language_sess');     $lang           = $langnamespace->lang;     $registry = zend_registry::getinstance();     $tr = new zend_translate(         array(             'adapter' => 'array',             'content' => application_path . "/languages/$lang/$lang.php",             'locale'  => "ar",             'scan' => zend_translate::locale_directory         )     );     $registry->set('zend_translate', $tr);     return $registry; } 

ok, make clear, need understand few things:

  • zend_translate supposed translate part of site, not related content. menu items, section names, titles, etc. might have exceptions rule, if use zend_translate_adapter_gettext.
  • for content, should use else provide translation. usually, example if static article, data db, not language file.

in case, if ok little bit "machine" translation, should use google translate engine sites

https://translate.google.com/manager/website/

as dropping $this->translate("text transfer"); part, can try translate data in controller, rather bad advice, advice else. when pass data view, can loop through , make translation each , everystring inside:

foreach($data $key => $string) {     $data[$key] = $tr->translate($string); } 

or that. bad approach because of few reasons. important not dividing presentation logic, , why best place view.

so summary:

  • try keep using $this->translate()
  • if not work you, try use google translate engine
  • if not you, try zend_translate_adapter_gettext.
  • please, not use language files content.

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -