Enter request scope if it is not active yet...

@param string $lang
192917
protected function enterRequestScope($lang)
    {
        $requestStack = $this->container->get('request_stack');
        // If there already is a request, get the locale from it.
        if ($requestStack->getCurrentRequest()) {
            $locale = $requestStack->getCurrentRequest()->getLocale();
        }
        // If we don't have a request or the current request locale is different from the node langauge
        if (!$requestStack->getCurrentRequest() || ($locale && $locale !== $lang)) {
            $request = new Request();
            $request->setLocale($lang);

            $context = $this->container->get('router')->getContext();
            $context->setParameter('_locale', $lang);

            $requestStack->push($request);
        }
    }
1106588
public function translationExists($lang, $alias) {
		$tree = $this->getTree($lang);

		foreach ($tree as $branch) {
			if (isset($branch[$alias])) return true;
		}
		return false;
	}
67269
public function lang($lang = NULL)
	{
		if ( ! func_num_args())
		{
			return $this->_lang;
		}
		$this->_lang = $lang;
		return $this;
	}
445166
public static function useCurrency(string $currency, ?string $symbol = null): void
    {
        static::$currency = $currency;
        static::useCurrencySymbol($symbol ?: static::guessCurrencySymbol($currency));
    }
261791
public function translationData($lang)
    {
        $translation = $this->translation($lang);

        if ($translation) {
            $data = json_decode($translation->entity_data);

            if (isset($data->blocks)) {
                $data->blocks = json_decode($data->blocks, true);
            }

            return $data;
        }

        return null;
    }
846877
public function setLang($request)
    {
        if (Auth::check()) {
            $user = Auth::user();

            // Set user locale
            if ($user->locale) {
                $this->setIfAllowed($user->locale);
            } else {
                if (config('localizer.set_auto_lang')) {
                    $this->setIfAllowed(Identify::lang()->getLanguage());
                } else {
                    $this->setIfAllowed(config('localizer.default_lang'));
                }
            }
        } else {
            if ($request->session()->has('locale')) {
                $this->setIfAllowed(session('locale'));
            } else {
                if (config('localizer.set_auto_lang')) {
                    $this->setIfAllowed(Identify::lang()->getLanguage());
                } else {
                    $this->setIfAllowed(config('localizer.default_lang'));
                }
            }
        }
    }
1341867
public function isIncludeDefaultLanguage($lang = null)
    {
        // if active lang is not passed in, use current active
        if (!$lang) {
            $lang = $this->getLanguage();
        }

        return !($this->default === $lang && $this->config->get('system.languages.include_default_lang') === false);
    }
226861
public function setLanguage($lang)
    {
        $this->clearCachedValueIf($this->lang != $lang);
        $this->lang = $lang;
    }
914705
public function setLang($lang)
    {
        if (2 !== strlen($lang)) {
            throw new \InvalidArgumentException('Language identifier should be 2 characters long.');
        }

        if (!in_array($lang, $this->getSupportedLanguages())) {
            throw new \InvalidArgumentException(sprintf('Language "%s" is not supported.', $lang));
        }

        $this->lang = $lang;

        return $this;
    }
464114
public static function set($lang = NULL) {
        $languages = get_config('langs');
        if (!$languages) {
            throw new \Exception(ExceptionMessages::MISCONFIGURED_LANG_CONFIG);
        }

        if (!get_config('lang_default')) {
            throw new \Exception(ExceptionMessages::MISCONFIGURED_LANG_DEFAULT_CONFIG);
        }

        if (empty($lang) || !in_array($lang, $languages)) {
            $lang = get_config('lang_default');
        }

        self::$currentLang = $lang;
        self::load($lang);
    }
37807
public function setLanguage($language)
    {
        if (!isset($this->keywords[$language])) {
            $this->language = 'en';
        } else {
            $this->language = $language;
        }
    }
1224378
private function setLocale($locale, $request)
    {
        $allowedLangs = array_keys(Localizer::allowedLanguages());
        if (config('localizer.block_unallowed_langs') && !in_array($locale, $allowedLangs)) {
            abort(404, 'Unallowed language');
        }

        if (Auth::check()) {
            $user = Auth::User();
            $user->locale = $locale;
            $user->save();
        } else {
            $request->session()->put('locale', $locale);
        }
    }
1199407
public function doesAcceptLanguage($language = 'en')
	{
		return (in_array(strtolower($language), $this->getAcceptLanguages(), true)) ? true : false;
	}
292396
public function set($lang) {
		if ($this->isValid($lang)) {
			$this->_language = $lang;
			$this->_l10n = $this->getL10n();

			// switch the locales
			$this->setLocale($this->_l10n['keys']);

			// clear content because language has changed
			$this->_content = null;
			return true;
		}
		return false;
	}
1190720
public function createRoot(Lang $lang) : void
    {
        if (php_sapi_name() !== 'cli')
        {
            throw new \Exception("Method createRoot() is allowed only in CLI mode.");
        }

        $root = $this->pageRepository->findOneAbsoluteRoot();

        if ($root === NULL)
        {
            $root = new Page;
            $root->setName('root');
            $root->setView('root');
            $root->makeRoot();
            $root->save();
        }

        $langRoot = $this->pageRepository->findOneLangRoot($lang, TRUE);

        if ($langRoot === NULL)
        {
            $langRootName = 'root-' . $lang->getName();

            $langRoot = new Page;
            $langRoot->setName($langRootName);
            $langRoot->setView($langRootName);
            $langRoot->setParent($root);
            $langRoot->insertAsLastChildOf($root);
            $langRoot->save();

            $this->pageUrlManager->saveUrl($lang, $langRoot, '__a@&*^-9' . $langRootName);
        }
    }
1107339
public function setLanguage($language = null)
    {
        if (is_null($language)) {
            if (($language = Yii::$app->request->getQueryParam('_lang')) !== null) {
                $this->language = $language;
                Yii::$app->response->cookies->add(new Cookie(['name' => '_lang', 'value' => $language]));
            } else if (($cookie = Yii::$app->request->cookies->get('_lang')) !== null) {
                $this->language = $cookie->value;
            } else if (($language = Yii::$app->request->getPreferredLanguage()) !== null) {
                $this->language = $language;
            }
        } else {
            $this->language = $language;
        }
    }
869256
public static function setLanguage($lang)
    {
        Application::$instance->i18n->setLanguage($lang);
        \Config::set('i18n.language', $lang);
    }