Detect language by user browser settings. Returns language ID if
detected, otherwise returns null.

@return int
501623
public function detectLanguageByBrowser()
    {
        $sBrowserLanguage = $this->_getBrowserLanguage();

        if (!is_null($sBrowserLanguage)) {
            $aLanguages = $this->getLanguageArray(null, true);
            foreach ($aLanguages as $oLang) {
                if ($oLang->abbr == $sBrowserLanguage) {
                    return $oLang->id;
                }
            }
        }
    }
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;
    }
1074046
public function getEditLanguage()
    {
        if ($this->_iEditLanguageId === null) {
            if (!$this->isAdmin()) {
                $this->_iEditLanguageId = $this->getBaseLanguage();
            } else {
                $iLang = null;
                // choosing language ident
                // check if we really need to set the new language
                if ("saveinnlang" == \OxidEsales\Eshop\Core\Registry::getConfig()->getActiveView()->getFncName()) {
                    $iLang = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("new_lang");
                }
                $iLang = ($iLang === null) ? \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('editlanguage') : $iLang;
                $iLang = ($iLang === null) ? \OxidEsales\Eshop\Core\Registry::getSession()->getVariable('editlanguage') : $iLang;
                $iLang = ($iLang === null) ? $this->getBaseLanguage() : $iLang;

                // validating language
                $this->_iEditLanguageId = $this->validateLanguage($iLang);

                // writing to session
                \OxidEsales\Eshop\Core\Registry::getSession()->setVariable('editlanguage', $this->_iEditLanguageId);
            }
        }

        return $this->_iEditLanguageId;
    }
1289216
public static function get_language_attributes()
    {
        ob_start();
        language_attributes();
        $r = ob_get_clean();
        $r = str_replace('"', '', $r);
        $r = str_replace(' ', '|', $r);
        
        return $r;
    }
1342548
protected function detect($uri=NULL) {
		$this->current=$this->primary;
		if (preg_match('/^'.preg_quote($this->f3->get('BASE'),'/').'\/([^\/?]+)([\/?]|$)/',$uri?:$_SERVER['REQUEST_URI'],$m) &&
				array_key_exists($m[1],$this->languages))
			$this->current=$m[1];
		else {//auto-detect language
			$this->auto=TRUE;
			$detected=array_intersect(explode(',',$this->f3->get('LANGUAGE')),explode(',',implode(',',$this->languages)));
			if ($detected=reset($detected))
				foreach($this->languages as $lang=>$locales)
					if (in_array($detected,explode(',',$locales))) {
						$this->current=$lang;
						break;
					}
		}
		$this->f3->set('LANGUAGE',$this->languages[$this->current]);
	}
576455
public function getDefaultLanguage()
    {
        if (!$this->defaultLanguage) {
            $language = substr(setlocale(LC_ALL, 0), 0, 2);
            $languages = $this->getLanguages();
            $languageDefault = reset($languages);
            $language = $this->isValidLanguage($language) ? $language : $languageDefault;
            $this->setDefaultLanguage($language);
        }

        return $this->defaultLanguage;
    }
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";
		}
	}
1209695
private function getFromAcceptedLanguagesHeader()
    {
        $matches = $this->getMatchesFromAcceptedLanguages();

        if ($locale = $this->inSupportedLocales($matches)) {
            return $locale;
        }

        // If any (i.e. "*") is acceptable, return the first supported locale
        if (isset($matches['*'])) {
            return $this->supportedLocales->first()->key();
        }

        return null;
    }
885526
public function getLang()
    {
        if ($this->_lang === null) {
            $this->_lang = $this->item->lang;
        }
        
        return $this->_lang;
    }
172960
public function getLang()
    {
        if ($this->_lang === null) {
            $this->_lang = $this->menu->composition['langShortCode'];
        }

        return $this->_lang;
    }
917159
private function _getCultureId()
    {
        $fallback = 'en_US';
        $supportedCultures = [
            'en_US' => '1033',
            'en_GB' => '2057',
            'fr_FR' => '1036',
            'es_ES' => '3082',
            'de_DE' => '1031',
            'it_IT' => '1040',
            'ru_RU' => '1049',
            'pt_PT' => '2070',
        ];
        $localeCode = $this->helper->getWebsiteConfig(\Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE);
        if (isset($supportedCultures[$localeCode])) {
            return $supportedCultures[$localeCode];
        }

        return $supportedCultures[$fallback];
    }
1037152
public function getLanguage()
    {
        if(!$language = $this->getUser()->getLanguage())
        {
            if ($this->_headers->has('Accept-Language')) {
                $language = locale_accept_from_http($this->_headers->get('Accept-Language'));
            } else {
                $language = $this->getConfig()->language;
            }
        }

        return $language;
    }
457528
public function getLocale()
    {
        $language = $this->getLanguage();
        $country = $this->getCountry();

        if (empty($language) || empty($country)) {
            return null;
        }

        return
            strtolower($language->getIso6391())
            . '_' .
            strtoupper($country->getIso2());
    }
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();
    }
1368297
public function getLanguageCode() {

		if (!$this->issetCache('lang')) {
	
			$query =
				'SELECT l.code' .
				' FROM `languages` AS l' .
				' INNER JOIN `locales` AS lc ON l.id = lc.language_id' .
				' INNER JOIN `users` AS u ON u.locale_id = lc.id' .
				' WHERE u.id = ?';
			$this->db->setQuery($query);
			$this->setCache('lang', $this->db->loadResult($this->id));

		}
	
		return $this->getCache('lang');

	}
572260
protected function detectCharacterEncoding()
    {
        $encoding = null;

        if (function_exists('nl_langinfo') && is_callable('nl_langinfo')) {
            $encoding = nl_langinfo(CODESET);
        } else {
            // try to detect encoding from locale identifier
            $lc_ctype = null;
            $lc_all = self::setlocale(LC_ALL, '0');
            $lc_all_exp = explode(';', $lc_all);
            if (count($lc_all_exp) === 1) {
                $lc_ctype = reset($lc_all_exp);
            } else {
                foreach ($lc_all_exp as $lc) {
                    if (strncmp($lc, 'LC_CTYPE', 8) === 0) {
                        $lc_ctype = $lc;
                        break;
                    }
                }
            }

            if ($lc_ctype !== null) {
                $lc_ctype_exp = explode('.', $lc_ctype, 2);
                if (count($lc_ctype_exp) === 2) {
                    $encoding = $lc_ctype_exp[1];
                }
            }
        }

        // assume encoding is a code-page if encoding is numeric
        if ($encoding !== null && ctype_digit($encoding)) {
            $encoding = 'CP' . $encoding;
        }

        return $encoding;
    }
1138388
public function getSessionLg()
    {

        $sessionLang = \common_session_SessionManager::getSession()->getDataLanguage();
        if (empty($sessionLang)) {
            throw new Exception('the data language of the user cannot be found in session');
        }

        return (string)$sessionLang;
    }