Exemplo n.º 1
0
 /**
  * Helper for the translateArrayValues Tal.
  *
  * This helper does the runtime translation of the supplied array
  * and returns a new array with the translated values.
  *
  * @param array                     $array      The array for translating.
  * @param PHPTAL_TranslationService $translator The translator object.
  *
  * @return array
  */
 public static function arrayTranslationHelper($array, $translator)
 {
     if (!is_array($array)) {
         return $array;
     }
     $results = array();
     foreach ($array as $key => $value) {
         $results[$key] = $translator->translate($value, false);
     }
     return $results;
 }
Exemplo n.º 2
0
 /**
  * Set I18N translator.
  *
  * This sets encoding used by the translator, so be sure to use encoding-dependent
  * features of the translator (e.g. addDomain) _after_ calling setTranslator.
  *
  * @param PHPTAL_TranslationService $t instance
  *
  * @return $this
  */
 public function setTranslator(PHPTAL_TranslationService $t)
 {
     $this->_translator = $t;
     $t->setEncoding($this->getEncoding());
     return $this;
 }