获取当前的目标语言

$lang = I18n::lang();
// 更改语言
I18n::lang('es-es');

@param  string $lang 要更改的语言
@return string
978277
public static function lang($lang = null)
    {
        if ($lang)
        {
            self::$lang = strtolower(str_replace(self::$_langNormalizeSearch, self::$_langNormalizeReplace, $lang));
        }
        return self::$lang;
    }
670835
protected function getLangPath()
    {
        $lang_folder_path = $this->config('lang_folder_path') ?: base_path('resources/lang');

        // Check path
        if (file_exists($lang_folder_path)) {
            return $lang_folder_path;
        }

        $this->error("No lang folder found in your custom path: \"{$lang_folder_path}\"");
        $this->line('');

        die();
    }
55884
public function getSslShopUrl($lang = null)
    {
        $url = $this->getShopUrlByLanguage($lang, true);

        if (!$url) {
            $url = $this->getMallShopUrl(true);
        }

        if (!$url) {
            $url = $this->getMallShopUrl();
        }

        //normal section
        if (!$url) {
            $url = $this->getConfigParam('sSSLShopURL');
        }

        if (!$url) {
            $url = $this->getShopUrl($lang);
        }

        return $url;
    }
203793
public static function languageToTerritory($lang) {
        $config = Zend_Registry::get('config');
        $territory = isset($config->resources->locale->territories->{$lang}) ?
            $config->resources->locale->territories->{$lang} :
            Zend_Locale::getLocaleToTerritory($lang);
        return $territory;
    }
573790
public function getLocale( $lang = null, $utf8 = true ) {
		$suffixes = $utf8 ? [ '.UTF-8', '.UTF-8', '.utf8' ] : [ '' ];
		$normal = isset( $lang ) ? $lang : $this->getLang();
		$normalUC = strtoupper( $normal );

		// Get 'foo' from 'foo-bar'
		$parts = explode( '-', $normal );
		$short = $parts[0];
		$shortUC = strtoupper( $short );

		$versions = [
			// foo-br or en
			$normal,
			// FOO-BR or EN
			$normalUC,
			// foo_FOO or en_EN
			$short . '_' . $shortUC,
			// foo or en
			$short,
			// FOO or EN
			$shortUC,
		];
		$return = [];
		foreach ( $versions as $version ) {
			foreach ( $suffixes as $suffix ) {
				$return[] = $version . $suffix;
			}
		}
		return array_values( array_unique( $return ) );
	}
38530
static function ModuleTranslationsFile(ModuleBase $module, $lang)
    {
        $folder = self::ModuleTranslationsFolder($module);
        $file = Path::Combine($folder, $lang);
        return Path::AddExtension($file, 'php');
    }
974018
public function getPlaceholder($lang = null)
    {
        $lang = empty($lang) ? $this->getDefaultLanguage() : $lang;

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

        return $this->placeholders[$lang];
    }
168409
public function out($lang = null) {
        if ($lang !== null && $lang != $this->lang && ($this->lang == null && $lang != current_language())) {
            if ($this->forcedstring) {
                debugging('lang_string objects that have been used cannot be printed in another language. ('.$this->lang.' used)', DEBUG_DEVELOPER);
                return $this->get_string();
            }
            $translatedstring = new lang_string($this->identifier, $this->component, $this->a, $lang);
            return $translatedstring->out();
        }
        return $this->get_string();
    }
210748
public function get_hyphenator( $lang ) {
		if ( isset( $this->cache[ $lang ] ) ) {
			return $this->cache[ $lang ];
		}

		return null;
	}
303611
public function getTranslations($lang)
    {
        $path = $this->getTranslationPathBaseDirectory('lang', $lang);

        if (!is_readable($path)) {
            return array();
        }

        $data = file_get_contents($path);
        $translations = json_decode($data, true);

        return $translations;
    }
966512
public function setLanguage($lang): bool
    {
        if (Arr::in($lang, App::$Properties->get('languages'))) {
            $this->language = $lang;
            return true;
        }

        return false;
    }
103511
public static String resolve( String lang ) {

		String result;
		if( ! LANGUAGES.contains( lang ))
			result = EN;
		else
			result = lang;

		return result;
	}
334252
public function getLanguageCode($lang = null)
    {
        $parts = $this->_callInternalLocale('parseLocale', null, $lang, false);
        return isset($parts['language']) ? $parts['language'] : null;
    }
1230367
public function getAll($lang = "")
    {
        $classNameArr = explode("\\", get_class($this));
        $className = "App\\Models\\".str_replace("Controller", "", $classNameArr[4]);
        $rowsPerPage = $className::$rowsPerPage;
        $class = new $className();

        $obj = DB::table($class->table);
        if(isset($_GET['order']) && isset($_GET['type'])) {
            $obj = $obj->orderBy($_GET['order'], $_GET['type']);
        }
        return $obj->simplePaginate($rowsPerPage);
    }
1108452
public function lang($isLang = true)
    {
        list($lang, $region) = explode('_', $this->locale);
        return ($isLang) ? Str::low($lang) : Str::low($region);
    }
339229
public static function parse( $lang ) 
	{
		$conf = ClanCats::$config->language;
		
		if ( isset( $lang ) && strlen( $lang ) > 1 ) 
		{
			$lang = explode( ',', strtolower( $lang ) );
			$lang = explode( '-', $lang[0] );
			
			if ( !isset( $lang[1] ) ) 
			{
				$lang[1] = $lang[0];
			}
			
			$available = $conf['available'];
			
			if ( array_key_exists( $lang[0], $available ) ) 
			{
				// does even the region match?
				if ( in_array( $lang[1], $available[$lang[0]] ) ) 
				{
					return $lang[0].'-'.$lang[1];
				}
				// return the first region
				else 
				{
					$locales = $available[$lang[0]];
					return $lang[0].'-'.$locales[key($locales)];
				}
			}
		}
		
		// Return the default language when nothing coul be matched
		return $conf['default'];
	}
1344675
private function extractDataOfLanguage($lang)
    {
        $found = [];
        // parsing language preference instructions
        // 2_digit_code[-longer_code][;q=coefficient]
        preg_match('/([a-z]{1,2})(-([a-z0-9]+))?(;q=([0-9\.]+))?/', $lang, $found);
        // 2 digit lang code
        $code = isset($found[1]) ? $found[1] : null;
        // lang code complement
        $morecode = isset($found[3]) ? $found[3] : null;
        // full lang code
        $fullcode = $morecode ? $code.'-'.$morecode : $code;
        // coefficient
        $coef = sprintf('%3.1f', isset($found[5]) ? $found[5] : '1');
        // for sorting by coefficient
        // adding
        return array('code' => $code,'coef' => $coef,'morecode' => $morecode,'fullcode' => $fullcode);
    }