Pimcore\Model\Translation\Admin::getByKeyLocalized PHP Метод

getByKeyLocalized() публичный статический Метод

public static getByKeyLocalized ( $id, boolean $create = false, boolean $returnIdIfEmpty = false, null $language = null ) : string
$id
$create boolean
$returnIdIfEmpty boolean
$language null
Результат string
    public static function getByKeyLocalized($id, $create = false, $returnIdIfEmpty = false, $language = null)
    {
        if ($user = Tool\Admin::getCurrentUser()) {
            $language = $user->getLanguage();
        } elseif ($user = Tool\Authentication::authenticateSession()) {
            $language = $user->getLanguage();
        } elseif (\Zend_Registry::isRegistered("Zend_Locale")) {
            $language = (string) \Zend_Registry::get("Zend_Locale");
        }
        if (!in_array($language, Tool\Admin::getLanguages())) {
            $config = \Pimcore\Config::getSystemConfig();
            $language = $config->general->language;
        }
        return self::getByKey($id, $create, $returnIdIfEmpty)->getTranslation($language);
    }

Usage Example

Пример #1
0
 private function translateLabel($key)
 {
     try {
         return \Pimcore\Model\Translation\Admin::getByKeyLocalized($key, false, true);
     } catch (\Exception $e) {
         return $key;
     }
 }
All Usage Examples Of Pimcore\Model\Translation\Admin::getByKeyLocalized