Ejemplo n.º 1
0
 /**
  * Get label translation 
  * 
  * @param string $code Language code OPTIONAL
  *  
  * @return \XLite\Model\LanguageLabelTranslation
  */
 public function getLabelTranslation($code = null)
 {
     $result = null;
     $query = \XLite\Core\Translation::getLanguageQuery($code);
     foreach ($query as $code) {
         $result = $this->getTranslation($code, true);
         if (isset($result) || 'en' == $code) {
             break;
         }
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Get translation in safe mode
  *
  * @param string $code Language code OPTIONAL
  *
  * @return \XLite\Model\Base\Translation
  */
 public function getSoftTranslation($code = null)
 {
     $result = null;
     // Select by languages query (current languge -> default language -> hardcoded default language)
     $query = \XLite\Core\Translation::getLanguageQuery($this->getTranslationCode($code));
     foreach ($query as $code) {
         $result = $this->getTranslation($code, true);
         if (isset($result)) {
             break;
         }
     }
     // Get first translation
     if (!isset($result)) {
         $result = $this->getTranslations()->first() ?: null;
     }
     // Get empty dump translation with specified code
     if (!isset($result)) {
         $result = $this->getTranslation(array_shift($query));
     }
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * Return translated category name
  *
  * :KLUDGE: it's the hack to prevent execution of superflous queries
  *
  * @param array $category Category data
  *
  * @return string
  */
 protected function getCategoryName(array $category)
 {
     $name = null;
     $query = \XLite\Core\Translation::getLanguageQuery(\XLite\Core\Session::getInstance()->getLanguage()->getCode());
     foreach ($query as $code) {
         $data = \Includes\Utils\ArrayManager::searchInArraysArray($category['translations'], 'code', $code);
         if (!empty($data)) {
             $name = $data['name'];
             break;
         }
     }
     return $name;
 }