Detect the used language.

@return string
961634
public static function detect($test = false)
    {
        if ($test) {
            return 'en';
        }

        $key = self::$sessionName;

        $cookieName = self::cookieName($key);

        // check if the session lang exists
        if (Session::exists($key)) {
            //check if supported languages contains the session lang value
            if (!in_array(Session::get($key), self::$supported)) {
                Session::put($key, config('lang.default', 'en'));
            }

            if (Cookie::existe($cookieName)) {
                if (Cookie::get($cookieName) != Session::get($key)) {
                    Cookie::create($cookieName, Session::get($key), config('lang.lifetime'));
                }
            } else {
                Cookie::create($cookieName, Session::get($key), config('lang.lifetime'));
            }
        } // check if the cookie lang exists
        elseif (Cookie::existe($cookieName)) {
            //check if supported languages contains the cookie lang value
            if (in_array(Cookie::get($cookieName), self::$supported)) {
                Session::put($key, Cookie::get($cookieName));
            } else {
                Session::put($key, config('lang.default', 'en'));
                Cookie::create($cookieName, config('lang.default', 'en'), config('lang.lifetime'));
            }
        } // if cokkie and session not found
        else {
            Session::put($key, config('lang.default', 'en'));
            Cookie::create($cookieName, config('lang.default', 'en'), config('lang.lifetime'));
        }

        return Session::get($key);
    }
885526
public function getLang()
    {
        if ($this->_lang === null) {
            $this->_lang = $this->item->lang;
        }
        
        return $this->_lang;
    }
739322
public function getLanguage()
    {
        if ($this->project->getEmailMultiLanguage() && $this->language) {
            return $this->language;
        } else {
            return $this->project->getLocaleDefault();
        }
    }
154351
public function getLanguagesSelector()
    {
        $view = new View("@LanguagesManager/getLanguagesSelector");
        $view->languages = API::getInstance()->getAvailableLanguageNames();
        $view->currentLanguageCode = self::getLanguageCodeForCurrentUser();
        $view->currentLanguageName = self::getLanguageNameForCurrentUser();
        return $view->render();
    }
629133
public function languageString()
    {
        $data = $data1 = $data2 = [];
        $language = $this->getLang();
        if (file_exists(route()->locale."{$language}.php")) {
            $data1 += require route()->locale."{$language}.php";
        }
        $path = route()->com;
        $disk_scan = array_diff(scandir($path), ['..', '.']);
        foreach ($disk_scan as $scans) {
            if (file_exists($path.$scans."/Locale/{$language}.php")) {
                $data2 += require $path.$scans."/Locale/{$language}.php";
            }
        }
        $data = array_merge($data1, $data2);

        return $data;
    }
1216268
public function toString()
    {
        if ($this->_language && $this->_culture) {
            return (string)$this->_language . '_' . (string)$this->_culture;
        } else {
            return (string)$this->_language;
        }
    }
884865
private function getLanguage()
    {
        $wpLang = (function_exists('get_locale')) ? get_locale() : null;
        $browserLang = null;
        if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
            $browserLang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
        }

        return  substr($wpLang ?: $browserLang ?: 'en', 0, 2);
    }
1332832
public function getLanguage()
    {
        if(!$language = $this->getUser()->getLanguage()) {
            $language = $this->getConfig()->language;
        }

        return $language;
    }
445687
public static function language()
	{
		// Create the batch selector to change the language on a selection list.
		$lines = array(
			'<label id="batch-language-lbl" for="batch-language" class="hasTip" title="' . Lang::txt('JLIB_HTML_BATCH_LANGUAGE_LABEL') . '::' . Lang::txt('JLIB_HTML_BATCH_LANGUAGE_LABEL_DESC') . '">',
			Lang::txt('JLIB_HTML_BATCH_LANGUAGE_LABEL'),
			'</label>',
			'<select name="batch[language_id]" class="inputbox" id="batch-language-id">',
			'<option value="">' . Lang::txt('JLIB_HTML_BATCH_LANGUAGE_NOCHANGE') . '</option>',
			Select::options(ContentLanguage::existing(true, true), 'value', 'text'),
			'</select>'
		);

		return implode("\n", $lines);
	}
1185649
public function getSelectedLanguage()
    {
        if (!class_exists(Locale::class) || !$this->hasMethod('Locales')) {
            return '';
        }

        /** @var ArrayData $information */
        $information = $this->LocaleInformation(FluentState::singleton()->getLocale());

        return $information->LanguageNative;
    }
252254
public function getLanguage() {
		if ($this->languageDetection === null) {
			$this->languageDetection = new BrowserLanguageDetection();
		}
		$language = $this->languageDetection->getLanguage();
		if (file_exists(ROOT_PATH.$this->i18nMessagePath.'message_'.$language.'.php')) {
			return $language;
		} else {
			return "default";
		}
	}
905189
public function getLanguage()
    {
        if ($this->_iLanguage === null) {
            $this->_iLanguage = \OxidEsales\Eshop\Core\Registry::getLang()->getBaseLanguage();
        }

        return $this->_iLanguage;
    }
990911
protected function detectLang()
    {
        /*
         * HTTP_ACCEPT_LANGUAGE -> fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
         * First "fr-FR" (preference 1/1)
         * After in the order, "fr" (preference 0.8 / 1)
         * Next "en-US" (preference 0.6/1)
         * End "en" (preference 0.4/1)
         **/
        
        $acceptLanguage = $this->serverValue('HTTP_ACCEPT_LANGUAGE');
        if (empty($acceptLanguage)) {
            $this->lang = '';
            return;
        }
        
        $acceptedLangs = explode(',', $acceptLanguage);
        $firstLang     = explode(';', $acceptedLangs[0]);
        $lang          = strtolower($firstLang[0]);

        if (strpos($lang, '-') !== false) {
            $minLang = explode('-', $lang);
            $lang    = $minLang[0];
        }

        $this->lang = $lang;
    }
585376
public function getLangClient() {
        if (!array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER) || !$_SERVER['HTTP_ACCEPT_LANGUAGE']) {
            return Config::config()['user']['output']['lang'];
        }
        else {
            $langcode = (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '';
            $langcode = (!empty($langcode)) ? explode(";", $langcode) : $langcode;
            $langcode = (!empty($langcode['0'])) ? explode(",", $langcode['0']) : $langcode;
            $langcode = (!empty($langcode['0'])) ? explode("-", $langcode['0']) : $langcode;

            return $langcode['0'];
        }
    }
810599
public function getLanguage() {
        if (!session_id()) {
            if ($this->sessionManager) {
                $this->sessionManager->start();
            }
        }
		if (!isset($_SESSION['_fine_I18n_language'])){
			$this->setLanguage('default');
		}
		return $_SESSION['_fine_I18n_language'];
	}
1187204
public function getUsedLanguages() {
		$alllanguages = $this->getAllLanguages();
		
		$usedlanguages = array();
		
		foreach ($alllanguages as $code=>$lang) {
			// check if lang folder and default file exists
			$langfile = $this->localespath.$code.'/default.txt';
			
			if (file_exists($langfile)) {
				$usedlanguages[$code] = $lang;
			}
		}
		
		return $usedlanguages;
	}
1041707
public function getCustomerLang()
    {
        $lang = $this->getLangModel();

        if ($lang === null) {
            $lang = (new LangQuery)
                ->filterByByDefault(1)
                ->findOne()
            ;
        }

        return $lang;
    }