public function transform($s, $force = false) { $langs = $this->split($s); if (is_string($langs)) { return $langs; } $lang = CMS::site_lang(); $rs = ''; if ($force) { if (isset($langs[$force])) { return $langs[$force]; } return ''; } if (isset($langs[$lang])) { $rs = trim($langs[$lang]); } if ($rs == '' && isset($langs['default'])) { $rs = trim($langs['default']); } if ($rs == '' && isset($langs[CMS::$default_lang])) { $rs = trim($langs[CMS::$default_lang]); } if ($rs == '') { $rs = $this->first_filled($langs); } return $rs; }
public function render() { if (!$this->type->access($this->name, $this->data, 'container_render', $this->item, $this)) { return ''; } $values = $this->value(); if (!is_array($values)) { return parent::render(); } return $values[CMS::site_lang()]; }
public function lang($lang = false) { $this->forced_lang = $lang ? $lang : CMS::site_lang(); return $this; }
protected function get_lang($data) { return $data['lang'] ? $data['lang'] : CMS::site_lang(); }
/** * Возвращает экземпляр языкового модуля (для многоязычных сайтов) * * @return CMS_Lang */ static function lang($code = false, $force = false) { if (!self::$user_lang) { Core::load('CMS.Lang'); self::$user_lang = new CMS_Lang(); self::$user_lang->init_module(self::site()); } if (self::$disable_lang) { if ($code || is_string($code)) { return $code; } return self::$user_lang; } if ($code || is_string($code)) { $code = (string) $code; if (Core_Regexps::match('{^[a-z0-9_]+$}i', $code)) { $bt = debug_backtrace(0); $bt = $bt[0]; return self::$user_lang->for_file($bt['file'], $code, $force); } if ($m = Core_Regexps::match_with_results('{^([^:]+):([^:]*):([^:]+)$}', $code)) { $lang = trim($m[1]); $comp = trim($m[2]); $parm = trim($m[3]); if ($lang == 'lang') { $l = CMS::site_lang(); if ($force) { CMS::site_set_lang($force); } $rc = self::$user_lang->{$comp}->{$parm}; CMS::site_set_lang($l); return $rc; } } return self::$user_lang->transform($code, $force); } return $code === false ? self::$user_lang : ''; }