Search code examples
phpzend-frameworkzend-translate

Is it possible for Zend_Translate to return multiple 'pieces' of content from a language file?


Started Googling today to research implementing Zend_Translate in a Zend 1.6.x project i have recently been assigned to. But i am finding it difficult to get to usable/appropriate sources of information.

Implemented simple Array adapter, which works nicely.

Basic overlay of the implementation as follows:

in the Language file:

 return array(
    'testKey' => 'Hello World!');

in SomeController.php: (added translate to the registry)

public function init()
{ 
    ...
      $this->_translate = Zend_Registry::get('translate');
    ...
}

in the view:

echo $translate->_('testKey');

I would like to know if it is possible to retrieve more than just one element from the language array? Something like:

$phraseList= $translate->_('lanKey1','lanKey1'..'n');
//or
$phraseList= $translate->_( array('lanKey1','lanKey1'..'n') );

Or at the least does anyone have resources to point out, or a direction to research in?

Many thanks, David


Solution

  • No, you can pass one item at a time.

    You can refer the source code. Its a better resource than a documentation.

    /**
         * Translates the given string
         * returns the translation
         *
         * @param  string             $messageId Translation string
         * @param  string|Zend_Locale $locale    (optional) Locale/Language to use, identical with locale
         *                                       identifier, @see Zend_Locale for more information
         * @return string
         */
        public function _($messageId, $locale = null)
        {
            return $this->translate($messageId, $locale);
    }
    

    FYI: Zend_Translate_Adapter