Returns True if language chosen by L= parameter matches language of content
Returns False if content is in fallback language

@return bool
548545
protected function checkIfNoLanguageFallback()
    {
        $tsfe = self::getTsfe();
        // Check if we have fallen back to a default language
        if (GeneralUtility::getLanguageId() !== $tsfe->sys_language_uid) {
            return false; //don't index untranslated page
        }
        return true;
    }
1044277
protected function validateLanguage()
    {
        $id = $this->getUpdatingId();

        if ($id === false) {
            return null;
        }

        $data = $this->language->get($id);

        if (empty($data)) {
            $this->setErrorUnavailable('update', $this->translation->text('Language'));
            return false;
        }

        $this->setUpdating($data);
        return true;
    }
277749
protected function validateCodeLanguage()
    {
        $field = 'code';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if ($this->isUpdating() && !isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        $label = $this->translation->text('Code');

        if (empty($value)) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        if (preg_match('/^[A-Za-z\\-]+$/', $value) !== 1) {
            $this->setErrorInvalid($field, $label);
            return false;
        }

        $updating = $this->getUpdating();

        if (isset($updating['code']) && $updating['code'] === $value) {
            return true;
        }

        $language = $this->language->get($value);

        if (!empty($language)) {
            $this->setErrorExists($field, $label);
            return false;
        }

        return true;
    }
966443
public function isTargetLanguageVersionExist(string $languageCode): bool
    {
        $languages = $this->repository->getContentLanguageService()->loadLanguages();
        foreach ($languages as $language) {
            if ($language->enabled && $language->languageCode == $languageCode) {
                return true;
            }
        }

        return false;
    }
520839
public function checkLanguage(string $key): bool
    {
        $locale = $this->getOption('locale', []);

        if (array_key_exists($key, Arr::wrap($locale))) {
            return filter_var($locale[$key], FILTER_VALIDATE_BOOLEAN);
        }

        return false;
    }
32311
public function matchesRequest()
    {
        return ! is_null($this->event->get('MsgType')) && ! is_null($this->event->get('MsgId')) && ($this->event->get('MsgType') === 'text' || $this->event->get('MsgType') === 'link');
    }
944631
public boolean showElementLanguageSelector() {

        List<Locale> locales = OpenCms.getLocaleManager().getAvailableLocales(getCms(), getParamResource());
        if ((locales == null) || (locales.size() < 2)) {
            // for less than two available locales, do not create language selector
            return false;
        }
        return true;
    }
542366
protected function detectCharset(): bool
    {
        // set the default
        $encode = new Encode;
        $encode->from($this->defaultCharset);
        $encode->to($this->defaultCharset);

        if ( ! is_null($this->options->enforceEncoding)) {
            //  they want to enforce the given encoding
            $encode->from($this->options->enforceEncoding);
            $encode->to($this->options->enforceEncoding);

            return false;
        }

        $meta = $this->root->find('meta[http-equiv=Content-Type]', 0);
        if (is_null($meta)) {
            // could not find meta tag
            $this->root->propagateEncoding($encode);

            return false;
        }
        $content = $meta->content;
        if (empty($content)) {
            // could not find content
            $this->root->propagateEncoding($encode);

            return false;
        }
        $matches = [];
        if (preg_match('/charset=(.+)/', $content, $matches)) {
            $encode->from(trim($matches[1]));
            $this->root->propagateEncoding($encode);

            return true;
        }

        // no charset found
        $this->root->propagateEncoding($encode);

        return false;
    }
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);
    }
1157620
protected function isSyntacticallyValid(): bool
    {
        if (!parent::isSyntacticallyValid()) {
            return false;
        }

        if (!$this->parsedUri->schemeEquals(Http::SCHEME)
          && !$this->parsedUri->schemeEquals(Http::SCHEME_SSL)) {
            return false;
        }

        return true;
    }
998724
public String validateFallbackLocale() {
        ULocale loc = ULocale.getDefault();
        if (loc != fallbackLocale) {
            synchronized (this) {
                if (loc != fallbackLocale) {
                    fallbackLocale = loc;
                    fallbackLocaleName = loc.getBaseName();
                    clearServiceCache();
                }
            }
        }
        return fallbackLocaleName;
    }
260873
public function detectlocale()
    {
        if (isset($GLOBALS['lang'])) {
            return $GLOBALS['lang'];
        } elseif (getenv('LC_ALL')) {
            return getenv('LC_ALL');
        } elseif (getenv('LC_MESSAGES')) {
            return getenv('LC_MESSAGES');
        } elseif (getenv('LANG')) {
            return getenv('LANG');
        }

        return 'en';
    }
984645
def get_fallback_language(self, language_code=None, site_id=None):
        
        choices = self.get_active_choices(language_code, site_id=site_id)
        if choices and len(choices) > 1:
            # Still take the last, like previous code.
            # With multiple fallback languages that means taking the base language.
            # Hence, upgrade the code to use get_fallback_languages() instead.
            return choices[-1]
        else:
            return None
1363019
public function match()
    {
        $elements = $this->getHostElements();

        return isset($elements[$this->elementNumber - 1]) ? $elements[$this->elementNumber - 1] : false;
    }
730801
public function getFallbackLanguage($forLanguage = null)
    {
        if ($this->_fallbackLanguage === null) {
            $this->_fallbackLanguage = Yii::$app->sourceLanguage;
        }
        if ($forLanguage === null) {
            return $this->_fallbackLanguage;
        }
        if ($this->_fallbackLanguage === false) {
            return $forLanguage;
        }

        if (is_array($this->_fallbackLanguage)) {
            if (isset($this->_fallbackLanguage[$forLanguage])) {
                return $this->_fallbackLanguage[$forLanguage];
            }
            // check fallback de-DE -> de
            $fallbackLanguage = substr($forLanguage, 0, 2);
            if ($forLanguage !== $fallbackLanguage) {
                return $fallbackLanguage;
            }
            // when no fallback is available, use the first defined fallback
            return reset($this->_fallbackLanguage);
        }

        // check fallback de-DE -> de
        $fallbackLanguage = substr($forLanguage, 0, 2);
        if ($forLanguage !== $fallbackLanguage) {
            return $fallbackLanguage;
        }
        return $this->_fallbackLanguage;
    }
125665
protected function storeSlugForLanguageId()
    {
        /** @var CmsModel|SluggableTrait $this */

        $config      = $this->getSluggableConfig();
        $languageKey = array_get($config, 'language_key');
        $localeKey   = array_get($config, 'locale_key');

        if ($languageKey) {
            return $this->getAttribute($languageKey);
        }

        if ($localeKey) {
            return $this->lookupLanguageIdForLocale( $this->getAttribute($localeKey) );
        }

        return null;
    }
408682
public function isSatisfiedBy($contentInfo): bool
    {
        $versions = $this->contentService->loadVersions($contentInfo);

        foreach ($versions as $checkedVersionInfo) {
            if ($checkedVersionInfo->isDraft()
                && $checkedVersionInfo->versionNo > $contentInfo->currentVersionNo
                && $checkedVersionInfo->initialLanguageCode === $this->languageCode
            ) {
                return true;
            }
        }

        return false;
    }