Get the language code of the current locale

@param string $lang The language to use
@return string The language code for the current locale
334252
public function getLanguageCode($lang = null)
    {
        $parts = $this->_callInternalLocale('parseLocale', null, $lang, false);
        return isset($parts['language']) ? $parts['language'] : null;
    }
1277738
public function getLanguage() : ?string 
    {
        if ( ! $this->hasLanguage()) {
            $this->setLanguage($this->getDefaultLanguage());
        }
        return $this->language;
    }
595125
public function getTranslation($lang)
    {
        // Check if locale given
        if (strpos($lang, '_')) {
            $parts = explode('_', $lang);
            $lang = array_shift($parts);
        }

        foreach ($this->getTranslations() as $translation) {
            if ($translation->getLang() === $lang) {
                return $translation;
            }
        }

        $translation = new LayoutTranslation($lang);
        $translation->setLayout($this);

        return $translation;
    }
747809
public function set($lang) {
    if (!array_key_exists($lang, $this->getList())) {
      throw new LanguageNotPresentException;
    }
    $this->locator->set($lang);
    return $lang;
  }
506160
public function getTree($lang = null) {
		if (is_null($lang)) $lang = $this->_language;

		$file = $this->_language_path . $lang . '/tree.php';
		return $this->_loadFile($file);
	}
1279308
private function loadLang($lang) {
        $locale = preg_replace_callback('/\b([a-z]{2})[-_](?:([a-z]{4})[-_])?([a-z]{2})\b/', function ($matches) {
            return $matches[1].'_'.(!empty($matches[2]) ? ucfirst($matches[2]).'_' : '').strtoupper($matches[3]);
        }, strtolower($lang));

        if (file_exists($filename = __DIR__.'/Lang/'.$locale.'.php')) {
            $this->lang = $locale;

            $this->number_word = include __DIR__.'/Lang/'.$locale.'.php';
            $this->currency = $this->number_word['currency'];

            return true;
        }
        throw new InvalidArgumentException('Unknown language ('.$lang.')');
    }
555777
public function getEmailAddress($lang = 'en')
    {
        $action = "get_email_address";
        $options = array(
            'lang' => $lang,
            'sid_token' => $this->sid_token,
        );

        return $this->client->get($action, $options);
    }
1080527
public static function get($args, $lang = null)
    {
        $lang = !is_null($lang) ? $lang : self::getLanguage();
        $args = is_array($args) ? $args : [$args, null];

        $text = $args[0];
        //unset($args[0]);

        $hash = md5($text);

        if (count(self::$translations) == 0) {
            if (file_exists(self::getFilePath())) {
                $json = file_get_contents(self::getFilePath());
                self::$translations = json_decode($json, true);
            }
        }

        if (isset(self::$translations[$hash])
            && isset(self::$translations[$hash][$lang])
        ) {
            if (!empty(self::$translations[$hash][$lang])) {
                $args[0] = self::$translations[$hash][$lang];
                return call_user_func_array('sprintf', $args);
            }
        } else {
            self::$translations[$hash]['origin'] = $text;
            foreach (self::getAvailableLanguages() as $language) {
                if (!isset(self::$translations[$hash][$language])) {
                    self::$translations[$hash][$language] = '';
                }
            }
            $json = json_encode(
                self::$translations,
                JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE
            );
            file_put_contents(self::getFilePath(), $json);
            self::$translations = json_decode($json, true);
        }

        return call_user_func_array('sprintf', $args);
    }
150391
public function setTranslatableLang($lang)
    {
        if (is_string($lang)) {
            $lang = new Lang($lang);
        }

        $this->translatableLang = $lang;

        return $this;
    }
329604
public function get_language_fullname($language)
    {
        //Clean up the language name to prevent malicious code injection
        $language = preg_replace('#[^a-zA-Z0-9\-_]#', '', $language);

        $language = strtolower($language);

        // get fullpath-filename for a langname
        $fullpath = $this->language_path.$language.'.php';

        // we need to get contents :S
        if (false === ($data = file_get_contents($fullpath))) {
            $this->error = sprintf('Geshi::get_lang_fullname() Unknown Language: %s', $language);
            return false;
        }

        // match the langname
        if (!preg_match('/\'LANG_NAME\'\s*=>\s*\'((?:[^\']|\\\')+?)\'/', $data, $matches)) {
            $this->error = sprintf('Geshi::get_lang_fullname(%s): Regex can not detect language', $language);
            return false;
        }

        // return fullname for langname
        return stripcslashes($matches[1]);
    }
922496
public function getLangName(?string $lang = null): string
    {
        if ($lang) {
            return $this->intuition->getLangName($lang);
        }
        return $this->intuition->getLangName($this->intuition->getLang());
    }
1032932
public function getLanguageCode($language = null)
    {
        if ($language === null) {
            $language = $this->_language;
        }
        $code = KlarnaLanguage::getCode($language);

        return (string) $code;
    }
1291504
public function getLanguageFullname($language)
    {
        //Clean up the language name to prevent malicious code injection
        $language = preg_replace('#[^a-zA-Z0-9\-_]#', '', $language);

        $language = strtolower($language);

        // get fullpath-filename for a langname
        $fullpath = self::LANG_ROOT . $language . '.php';

        // we need to get contents :S
        if (false === ($data = file_get_contents($fullpath))) {
            $this->error = sprintf('%s->%s Unknown Language: %s', __CLASS__, __METHOD__, $language);

            return false;
        }

        // match the langname
        if (!preg_match('/\'LANG_NAME\'\s*=>\s*\'((?:[^\']|\\\')+?)\'/', $data, $matches)) {
            $this->error = sprintf('%s->%s(%s): Regex can not detect language', __CLASS__, __METHOD__, $language);

            return false;
        }

        // return fullname for langname
        return stripcslashes($matches[1]);
    }
172960
public function getLang()
    {
        if ($this->_lang === null) {
            $this->_lang = $this->menu->composition['langShortCode'];
        }

        return $this->_lang;
    }
477637
public function getLanguage( $language )
	{
		$pattern		= '/^([a-z]{1,8}(?:-[a-z]{1,8})*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i';
		if( !$language )
			return $this->default;
		$accepted	= preg_split( '/,\s*/', $language );
		$curr_lang	= $this->default;
		$curr_qual	= 0;
		foreach( $accepted as $accept)
		{
			if( !preg_match ( $pattern, $accept, $matches) )
				continue;
			$lang_code = explode ( '-', $matches[1] );
			$lang_quality =  isset( $matches[2] ) ? (float)$matches[2] : 1.0;
			while (count ($lang_code))
			{
				if( in_array( strtolower( join( '-', $lang_code ) ), $this->allowed ) )
				{
					if( $lang_quality > $curr_qual )
					{
						$curr_lang	= strtolower( join( '-', $lang_code ) );
						$curr_qual	= $lang_quality;
						break;
					}
				}
				array_pop ($lang_code);
			}
		}
		return $curr_lang;
	}
723994
public static function set_current( $lang ) 
	{
		$lang = static::parse( $lang );
		
		if ( !array_key_exists( $lang, static::$data ) ) 
		{
			static::$data[$lang] = array();
		}
		
		return static::$current_language = $lang;
	}
611308
public function getTranslation($lang)
    {
        // Check if locale given
        if (strpos($lang, '_')) {
            $parts = explode('_', $lang);
            $lang = array_shift($parts);
        }

        foreach ($this->getTranslations() as $translation) {
            if ($translation->getLang() === $lang) {
                return $translation;
            }
        }

        $translation = new EmailTranslation($lang);
        $translation->setEmail($this);

        return $translation;
    }