Translator.php

00001 <?php
00009 class Dsao_Controller_Action_Helper_Translator
00010   extends Zend_Controller_Action_Helper_Abstract
00011 {
00015   protected $_locale = null;
00016 
00020   protected $_translate = null;
00021 
00027   public function getLocale()
00028   {
00029     // Falls Locale noch nicht initialisiert
00030     if (null === $this->_locale)
00031     {
00032       $this->_locale = Dsao_Registry::get('user')
00033         ->getData('locale', 'de');
00034     }
00035 
00036     return $this->_locale;
00037   }
00038 
00044   public function getTranslate()
00045   {
00046     return $this->_translate;
00047   }
00048 
00054   public function init()
00055   {
00056     // Falls Translate-Objekt bereits initialisiert wurde, abbrechen
00057     if (null !== $this->_translate)
00058     {
00059       return;
00060     }
00061 
00062     // Translate-Objekt laden
00063     $this->_translate = Dsao_Registry::get('translate');
00064 
00065     // Adapter
00066     $adapter = $this->_translate->getAdapter();
00067 
00068     // Sofern sich momentane Sprache und vom Benutzer eingestellte Sprache
00069     // unterscheiden, umstellen
00070     if ($adapter->getLocale() != $this->getLocale())
00071     {
00072       // Sprache ändern
00073       $adapter->setLocale($this->getLocale());
00074     }
00075 
00076     // Standardsprachdatei für alle Layouts laden
00077     $adapter->addLayoutTranslationData('default');
00078 
00079     // Ggf. Sprachdatei des vom Benutzer gewählten Layouts hinzufügen
00080     $adapter->addLayoutTranslationData
00081       ($this->getActionController()->getUser()->layout);
00082   }
00083 }

Erzeugt am Fri Sep 18 19:04:11 2009 für DSA online - Morgendaemmerung von  doxygen 1.5.7.1