nerkn
nerkn

Reputation: 1980

zend translate for view & controller

I initialize translation in controller.

public function init(){
  $this->translate  = new Zend_Translate('csv', '../application/configs/translate.tr', 'tr');

But I want to use translate in view. Should I initialize as the same way as controller? How can I implement what?

Upvotes: 0

Views: 2595

Answers (1)

takeshin
takeshin

Reputation: 50638

Just initialize the translation in application.ini. The application resource will we available everywhere.

Example:

resources.translate.registry_key = "Zend_Translate"
resources.translate.adapter = "gettext"
resources.translate.options.logUntranslated = false
resources.translate.options.scan = "directory"
resources.translate.options.disableNotices = 1
;resources.translate.options.logfile = APPLICATION_PATH "/../data/log/application.log"
resources.translate.data = APPLICATION_PATH "/../data/languages"
resources.translate.locale = "fr" ; default language

You may also get Zend_Translate instance from the registry.

Upvotes: 4

Related Questions