getString($key, self::$lang, $args); } /** * @param $key * @param $lang * @param $args * * @return string */ private function getString($key, $lang, $args): string { $redLang = strtolower(substr($lang, 0, 2)); if (array_key_exists($lang, $this->cache)) { $transDict = $this->cache[$lang]; } else { if (file_exists(self::$langPath.$lang.'.lang.php')) { $transDict = include self::$langPath.$lang.'.lang.php'; $this->cache[$lang] = $transDict; } else { if (file_exists(self::$langPath.$redLang.'.lang.php')) { $transDict = include self::$langPath.$redLang.'.lang.php'; $this->cache[$lang] = $transDict; } else { $transDict = []; } } } if (array_key_exists($key, $transDict)) { $string = @vsprintf($transDict[$key], $args); if ($string !== false) { return $string; } } if ($lang !== self::DEFAULT_LANG) { return $this->getString($key, self::DEFAULT_LANG, $args); } return $key; } }