Validate language id. If not valid id, returns default value

@param int $iLang Language id

@return int
422551
public function validateLanguage($iLang = null)
    {
        // checking if this language is valid
        $aLanguages = $this->getLanguageArray(null, !$this->isAdmin());
        if (!isset($aLanguages[$iLang]) && is_array($aLanguages)) {
            $oLang = current($aLanguages);
            if (isset($oLang->id)) {
                $iLang = $oLang->id;
            }
        }

        return (int) $iLang;
    }
1111365
public function isValid($translations)
    {
        $this->message = null;

        if (empty($translations['General']['Locale'])) {
            $this->message = self::ERRORSTATE_LOCALEREQUIRED;
            return false;
        }

        if (empty($translations['General']['TranslatorName'])) {
            $this->message = self::ERRORSTATE_TRANSLATORINFOREQUIRED;
            return false;
        }

        /** @var LanguageDataProvider $languageDataProvider */
        $languageDataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\LanguageDataProvider');
        /** @var RegionDataProvider $regionDataProvider */
        $regionDataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\RegionDataProvider');

        $allLanguages = $languageDataProvider->getLanguageList();
        $allCountries = $regionDataProvider->getCountryList();

        if ('eo.UTF-8' === $translations['General']['Locale']) {
            return true;
        }

        if (!preg_match('/^([a-z]{2})_([A-Z]{2})\.UTF-8$/', $translations['General']['Locale'], $matches)) {
            $this->message = self::ERRORSTATE_LOCALEINVALID;
            return false;
        } else if (!array_key_exists($matches[1], $allLanguages)) {
            $this->message = self::ERRORSTATE_LOCALEINVALIDLANGUAGE;
            return false;
        } else if (!array_key_exists(strtolower($matches[2]), $allCountries)) {
            $this->message = self::ERRORSTATE_LOCALEINVALIDCOUNTRY;
            return false;
        }

        return true;
    }
1360844
public function getBaseSeoLink($iLang, $iPage = 0)
    {
        $oEncoder = \OxidEsales\Eshop\Core\Registry::get(\OxidEsales\Eshop\Application\Model\SeoEncoderCategory::class);
        if (!$iPage) {
            return $oEncoder->getCategoryUrl($this, $iLang);
        }

        return $oEncoder->getCategoryPageUrl($this, $iPage, $iLang);
    }
359344
public function getStdLink($iLang = null, $aParams = [])
    {
        if ($iLang === null) {
            $iLang = (int) $this->getLanguage();
        }

        $iLinkType = $this->getLinkType();
        if (!isset($this->_aStdUrls[$iLang][$iLinkType])) {
            $oArticle = oxNew(\OxidEsales\Eshop\Application\Model\Article::class);
            $oArticle->setId($this->getId());
            $oArticle->setLinkType($iLinkType);
            $this->_aStdUrls[$iLang][$iLinkType] = $oArticle->getStdLink($iLang, $aParams);
        }

        return $this->_aStdUrls[$iLang][$iLinkType];
    }
10760
private function resolveLanId(): void
  {
    $codes = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? null);

    // If HTTP_ACCEPT_LANGUAGE is not set or empty return the default language.
    if (empty($codes)) $this->lanIdDefault;

    $map = Abc::$babel->getInternalLanguageMap();

    // Try to find the language code. Examples: en, en-US, zh, zh-Hans.
    // BTW We assume HTTP_ACCEPT_LANGUAGE is sorted properly.
    foreach ($codes as &$code)
    {
      // The official language code for Dutch in the Netherlands is nl-NL (with hyphen). But in practice we encounter
      // nl_NL, nl_nl, nl-nl. Therefore, internal language codes are in lower case and with hyphen.

      // Remove sorting weight, replace underscore with dash, and convert to lower case.
      $code = strtolower(str_replace('_', '-', strtok($code, ';')));

      if (isset($map[$code]))
      {
        $this->lanId = $map[$code];

        return;
      }
    }

    // We did not find the language code. Try without county code. Examples: en, zh.
    foreach ($codes as $code)
    {
      $code = substr($code, 0, 2);

      if (isset($map[$code]))
      {
        $this->lanId = $map[$code];

        return;
      }
    }

    // We did not find the language code. Use the ID of the default language.
    $this->lanId = $this->lanIdDefault;
  }
628181
public function getLanguage($vocabulary_id, $language_id = null)
    {
        if (!$this->isTranslatable($vocabulary_id)) {
            return 1;
        }

        if ($language_id === null) {
            return I18N::getCurrentId();
        }

        return $language_id;
    }
1006365
static function removeLanguage( $id )
    {
        $language = eZContentLanguage::fetch( $id );
        if ( $language )
        {
            return $language->removeThis();
        }
        else
        {
            return false;
        }
    }
1254910
public function getContentUrl($oCont, $iLang = null)
    {
        if (!isset($iLang)) {
            $iLang = $oCont->getLanguage();
        }

        return $this->_getFullUrl($this->getContentUri($oCont, $iLang), $iLang);
    }
164871
private function _checkLanguage(&$language)
    {
        if (!isset($language)) {
            throw new Klarna_ArgumentNotSetException("Language");
        }
        if (is_numeric($language) && !is_int($language)) {
            $language = intval($language);
        }
        if (!is_numeric($language) || !is_int($language)) {
            throw new Klarna_InvalidTypeException("Language", "integer");
        }
    }
1335509
private function _checkIdArgument($id)
    {
        $id = strtoupper($id);
        $length = strlen($id);

        if ($length === 15) {
            return $this->_generateShortType($id);
        } elseif ($length === 18) {
            return $this->_generatelongType($id);
        }

        return false;
    }
915027
public static function getById($id)
    {
        $result = null;
        $info = CldrData::getLanguageInfo($id);
        if (isset($info)) {
            $result = new Language($info);
        }

        return $result;
    }
1278050
public function getActLanguageId()
    {
        if (($sValue = $this->getViewConfigParam('lang')) === null) {
            $iLang = $this->getConfig()->getRequestParameter('lang');
            $sValue = ($iLang !== null) ? $iLang : \OxidEsales\Eshop\Core\Registry::getLang()->getBaseLanguage();
            $this->setViewConfigParam('lang', $sValue);
        }

        return $sValue;
    }
752761
public function getIdentifier() : ?int 
    {
        if ( ! $this->hasIdentifier()) {
            $this->setIdentifier($this->getDefaultIdentifier());
        }
        return $this->identifier;
    }
1211527
public function intlFormatter($language = null)
    {
        if ($language === null) {
            $language = \Yii::$app->language;
        }

        if (isset(self::$lanquages[$language])) {
            return self::$lanquages[$language];
        }

        $formatter = new \skeeks\modules\cms\money\IntlFormatter($language);

        self::$lanquages[$language] = $formatter;
        return $formatter;
    }
982236
public function getBaseSeoLink($iLang, $iPage = 0)
    {
        $oEncoder = \OxidEsales\Eshop\Core\Registry::get(\OxidEsales\Eshop\Application\Model\SeoEncoderRecomm::class);
        if (!$iPage) {
            return $oEncoder->getRecommUrl($this, $iLang);
        }

        return $oEncoder->getRecommPageUrl($this, $iPage, $iLang);
    }
1136222
public function getLanguageUid(int $default = null): int {
    $languageUid = $default ?: 0;

    if (TYPO3_MODE === 'FE') {
      if (isset($GLOBALS['TSFE']->sys_language_uid)) {
        $languageUid = $GLOBALS['TSFE']->sys_language_uid;
      }
    } elseif (is_object($GLOBALS['LANG'])) {
      if (isset($GLOBALS['LANG']->sys_language_uid)) {
        $languageUid = $GLOBALS['LANG']->sys_language_uid;
      }
    }

    return $languageUid;
  }
541667
public function getLink($iLang = null, $blMain = false)
    {
        if (!\OxidEsales\Eshop\Core\Registry::getUtils()->seoIsActive()) {
            return $this->getStdLink($iLang);
        }

        if ($iLang === null) {
            $iLang = $this->getLanguage();
        }

        $iLinkType = $this->getLinkType();
        if (!isset($this->_aSeoUrls[$iLang][$iLinkType])) {
            $this->_aSeoUrls[$iLang][$iLinkType] = $this->getBaseSeoLink($iLang, $blMain);
        }

        $sUrl = $this->_aSeoUrls[$iLang][$iLinkType];
        if (isset($this->_aSeoAddParams[$iLang])) {
            $sUrl .= ((strpos($sUrl . $this->_aSeoAddParams[$iLang], '?') === false) ? '?' : '&amp;') . $this->_aSeoAddParams[$iLang];
        }

        return $sUrl;
    }