Multilanguage in Zend

Posted by | February 13, 2012 | PHP, Zend | No Comments

Unfortunately not all of us are spoking the same language, hmm..  weird isn’t it  ? So is this affecting me as a developer ? would you ask ? actually yes my fellow, it does. If is the first tine when you are developing a multi-language web application you will have to solve a lot of problems that normally you wouldn’t have, yes.. you will ! OK so I am not going to explain the paint you will have to endure, but I will show you how to do that in Zend, just follow the steps:

  • Step 1: add a method in the almighty Bootsrap.php something like this:
protected function _initLanguage() {
 $zl = new Zend_Locale();
 Zend_Registry::set('Zend_Locale', $zl);
 $lang = 'ro';
 $translate = new Zend_Translate('csv', APPLICATION_PATH . '/configs/lang/' . $lang . '.csv', $lang);
 Zend_Registry::set('Zend_Translate', $translate);
 return $translate;
  • Step 2: add the language files in the APPLICATION_PATH /configs/lang/ this are some  strange csv files 🙂 .
  • Step 3: hmm … there is no step 3


About Andrei Tara

Andrei is a developer/geek who loves creating high quality and efficient applications, always following the best practices in software engineering. He loves the challenge of learning new, exciting things and playing with new languages, frameworks, and tools.

Leave a Reply