Get locale data from input array or serialized string
@param array|string $input
@param string|null $lang
@param string|null $default
@return string|null
487145
public function getLocaleText($input, ?string $lang = null, ?string $default = null): ?string
    {
        // define language if empty
        if ($lang === null) {
            $lang = App::$Request->getLanguage();
        }
        // unserialize from string to array
        if (Any::isStr($input)) {
            $input = Serialize::decode($input);
        }

        if (Any::isArray($input) && array_key_exists($lang, $input)) {
            return $input[$lang];
        }

        return $default;
    }
1125565
public function getLabel($lang = null)
    {
        $lang = empty($lang) ? $this->getDefaultLanguage() : $lang;

        if (!isset($this->labels[$lang])) {
            return $this->getFirstLabel();
        }

        return $this->labels[$lang];
    }
16157
public static function __($message, $params = [], $language = null)
    {
        return Yii::t(static::$defaultContext, $message, $params, $language);
    }
549545
public static function getMetadata($lang)
	{
		$path = self::getLanguagePath(JPATH_ROOT, $lang);
		$file = $lang . '.xml';

		$result = null;

		if (is_file("$path/$file"))
		{
			$result = self::parseXMLLanguageFile("$path/$file");
		}

		if (empty($result))
		{
			return null;
		}

		return $result;
	}
1309210
public function load_data($input = null) {
        $data = null;
        $file = null;

        if (is_null($input)) {
            $file = $this->file;
        } elseif (\strlen($input) <= PHP_MAXPATHLEN && file_exists($input)) {
            $file = $input;
        } else {
            $data = $input;
        }

        if (!empty($data) || $data = $this->_rfile($file)) {
            if ($this->file != $file) {
                $this->file = $file;
            }

            if (preg_match('/\.php$/i', $file) && preg_match('/<\?.*?\?>(.*)/ms', $data, $strip)) {
                $data = ltrim($strip[1]);
            }

            if (strpos($data, "\xef\xbb\xbf") === 0) {
                // strip off BOM (UTF-8)
                $data = substr($data, 3);
                $this->encoding('UTF-8');
            } elseif (strpos($data, "\xff\xfe") === 0) {
                // strip off BOM (UTF-16 little endian)
                $data = substr($data, 2);
                $this->encoding("UCS-2LE");
            } elseif (strpos($data, "\xfe\xff") === 0) {
                // strip off BOM (UTF-16 big endian)
                $data = substr($data, 2);
                $this->encoding("UTF-16");
            }

            if ($this->convert_encoding && $this->input_encoding !== $this->output_encoding) {
                $data = $this->use_mb_convert_encoding ?
                    mb_convert_encoding($data, $this->output_encoding, $this->input_encoding) :
                    iconv($this->input_encoding, $this->output_encoding, $data);
            }

            if (substr($data, -1) != "\n") {
                $data .= "\n";
            }

            $this->file_data = &$data;
            return true;
        }

        return false;
    }
1349192
public static function get($string, $lang = null)
    {
        if ( ! $lang)
        {
            $lang = self::$lang;
        }
        // 加载语言表
        $table = self::load($lang);

        return isset($table[$string]) ? $table[$string] : $string;
    }
544007
protected function fillArrayInput(array $input, $default = 0)
    {
        if (empty($input)) {
            return [];
        }

        $res = array_fill($default, max(array_keys($input)), null);

        foreach ($input as $index => $value) {
            $res[$index] = $value;
        }

        return $res;
    }
855846
public function input($input = null, $default = null)
    {
        // Get all inputs
        $inputs = array_merge($this->getInputs(), $this->additionalInputs);

        // Exclude reserved inputs
        foreach ($inputs as $key => $value) {
            if (in_array($key, $this->reserved)) {
                unset($inputs[$key]);
            }
        }

        // Return one input
        if ($input) {
            return isset($inputs[$input])? $inputs[$input] : $default;
        }

        // Or the complete array of inputs
        return $inputs;
    }
377053
public function input($key = null, $default = null)
    {
        $input = $this->getInputSource()->all() + $this->query->all();

        return array_get($input, $key, $default);
    }
323839
protected function l10nVal($val, $lang = null)
    {
        if (!is_string($lang)) {
            if (is_array($lang) && isset($lang['lang'])) {
                $lang = $lang['lang'];
            } else {
                $lang = $this->translator()->getLocale();
            }
        }

        if (isset($val[$lang])) {
            return $val[$lang];
        } else {
            return null;
        }
    }
540625
protected function getPreferredLanguage($default='en-US')
    {
        $acceptedLanguages = $this->getServerCollection()->get('HTTP_ACCEPT_LANGUAGE');

        // regex inspired from @GabrielAnderson on http://stackoverflow.com/questions/6038236/http-accept-language
        preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})*)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $acceptedLanguages, $lang_parse);
        $langs = $lang_parse[1];
        $ranks = $lang_parse[4];

        // (create an associative array 'language' => 'preference')
        $lang2pref = array();
        for($i=0; $i<count($langs); $i++) {
            $lang2pref[$langs[$i]] = (float) (!empty($ranks[$i]) ? $ranks[$i] : 1);
        }

        // (comparison function for uksort)
        $cmpLangs = function ($a, $b) use ($lang2pref) {
            if ($lang2pref[$a] > $lang2pref[$b])
                return -1;
            elseif ($lang2pref[$a] < $lang2pref[$b])
                return 1;
            elseif (strlen($a) > strlen($b))
                return -1;
            elseif (strlen($a) < strlen($b))
                return 1;
            else
                return 0;
        };

        // sort the languages by prefered language and by the most specific region
        uksort($lang2pref, $cmpLangs);

        $tokens = array_keys($lang2pref);
        $current = array_shift($tokens);
        
        if (strlen($current) !== strlen($default)) {
            return ($default !== null) ? $default : $current;
        }
        
        return $current;
    }
985653
function getLocale(lang) {
  lang = lang.toLowerCase();
  if (!locales.hasOwnProperty(lang)) {
    locales[lang] = {};
    try {
      locales[lang] = require('../locale/' + lang);
    } catch (err) {
      if (lang !== 'en') {
        return getLocale('en');
      }
      // This is not reachable, unless someone deletes ../locale/en.json
      throw err;
    }
  }

  return locales[lang];
}
213970
public function email($input, $key, $lang)
    {
        $lang = $this->custom('email', $lang);
        if (filter_var($input[$key], FILTER_VALIDATE_EMAIL) === false) {
            return str_replace(':field', $key, $lang);
        }
    }
807925
protected function get($string, $lang)
	{
		// If fallbacks are used, split language parts and iterate each reader using each part.
		// If fallbacks are not used, just use the specified language and let the reader implementation
		// take care of the translation fallbacks.
		$lang_fallback_path = $this->_use_fallback
			? $this->split_lang($lang)
			: array($lang);
		foreach ($lang_fallback_path as $lang)
		{
			foreach ($this->_readers as $reader)
			{
				if (($translation = $reader->get($string, $lang)))
				{
					return $translation;
				}
			}
		}
		return $string;
	}
132925
public function required($input, $key, $lang)
    {
        $lang = $this->custom('required', $lang);
        if (empty($input[$key])) {
            return str_replace(':field', $key, $lang);
        }
    }
714867
public static function getString($name, $default = null)
    {
        if (isset($_GET[$name]) && $_GET[$name] !== '') return self::parseInputToString($_GET[$name]);
        return $default;
    }
1074239
public function lang_get($params) {
        if (isset($params['line'])) {
            $parameters = isset($params['params']) ? $params['params'] : array();
            $default = isset($params['default']) ? $params['default'] : null;
            $language = isset($params['lang']) ? $params['lang'] : null;
            return Lang::get($params['line'], $parameters, $default, $language);
        }
        return false;
    }