0

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

hakre
  • 193,403
  • 52
  • 435
  • 836
David 'the bald ginger'
  • 1,296
  • 3
  • 20
  • 38
  • @JellyBelly we build rather large blocks of content on pages from the PHP side. Using language files we would need to replace various sections of the output, one by one, with the way Zend allows it. I was hoping one would be able to retrieve whole sets from a language file and use sprintf() to replace multiple sections at once in a large block of content. ( hope i explained that correctly :P ) – David 'the bald ginger' Jun 28 '12 at 05:59

1 Answers1

3

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

Venu
  • 7,243
  • 4
  • 39
  • 54
  • i slowly came to realise, last night, that the source is the better form of documentation for Zend. Thank you for the answer. I shall proceed to make my own little function to resolve my issue. :) – David 'the bald ginger' Jun 28 '12 at 05:54