Retrive language ID by code

@throws \InvalidArgumentException for unknown short code
@param string $shortCode     language code i.e. ru, cn etc
@return string              language's uuid
767892
public function getLanguageId(string $shortCode): string
    {
        $query = $this->Languages->find('all', [
            'conditions' => ['Languages.code' => $shortCode]
        ]);
        $language = $query->first();

        if (empty($language->id)) {
            throw new InvalidArgumentException("Unsupported language code [$shortCode]");
        }

        return $language->id;
    }
1202240
public function getLabel( $languageCode = 1033 ) {
        if ( !array_key_exists( $languageCode, $this->localizedLabel ) ) {
            $languageCode = 1033;
        }

        return $this->localizedLabel[$languageCode];
    }
157350
public function getNativeName($languageCode = null): ?string
    {
        $languageCode = $languageCode ? mb_strtolower($languageCode) : null;

        return $this->get("name.native.{$languageCode}.common")
            ?: (current($this->get('name.native', []))['common'] ?: $this->get('native_name'));
    }
869269
public static function getLangResourceByCode($code)
    {
        $langs = self::getAvailableLangs();
        return isset($langs[$code]) ? new core_kernel_classes_Resource($langs[$code]['uri']) : null; 
    }
1099920
public function getTranslation( $identifier, $defaultTranslation = null ) : string
   {

      if ( $this->_useNumericId )
      {

         // Not integer identifier. End here with an exception
         if ( ! \is_int( $identifier ) )
         {
            throw new \InvalidArgumentException( 'Current ' . __CLASS__ . ' instance requires numeric identifier!' );
         }

         // The identifier not exists, return the default translation
         if ( ! isset( $this->_translations[ $identifier ] ) )
         {
            return $defaultTranslation;
         }

         // Return string translation as it
         if ( \is_string( $this->_translations[ $identifier ] ) )
         {
            return $this->_translations[ $identifier ];
         }

         // Handle translation array values
         if ( \is_array( $this->_translations[ $identifier ] ) )
         {

            if ( isset( $this->_translations[ $identifier ][ 'text' ] ) )
            {
               return $this->_translations[ $identifier ][ 'text' ];
            }

            if ( isset( $this->_translations[ $identifier ][ 'value' ] ) )
            {
               return $this->_translations[ $identifier ][ 'value' ];
            }

            if ( isset( $this->_translations[ $identifier ][ 'translation' ] ) )
            {
               return $this->_translations[ $identifier ][ 'translation' ];
            }

         }

         // No translation found
         return $defaultTranslation;

      }

      // Not integer identifier. End here with an exception
      if ( ! \is_string( $identifier ) )
      {
         throw new \InvalidArgumentException( 'Current ' . __CLASS__ . ' instance requires string identifier!' );
      }

      // The identifier not exists, return the default translation
      if ( ! isset( $this->_translations[ $identifier ] ) )
      {
         return empty( $defaultTranslation ) ? $identifier : $defaultTranslation;
      }

      // Return string translation as it
      if ( \is_string( $this->_translations[ $identifier ] ) )
      {
         return $this->_translations[ $identifier ];
      }

      // Handle translation array values
      if ( \is_array( $this->_translations[ $identifier ] ) )
      {

         if ( isset( $this->_translations[ $identifier ][ 'text' ] ) )
         {
            return $this->_translations[ $identifier ][ 'text' ];
         }

         if ( isset( $this->_translations[ $identifier ][ 'value' ] ) )
         {
            return $this->_translations[ $identifier ][ 'value' ];
         }

         if ( isset( $this->_translations[ $identifier ][ 'translation' ] ) )
         {
            return $this->_translations[ $identifier ][ 'translation' ];
         }

      }

      return empty( $defaultTranslation ) ? $identifier : $defaultTranslation;

   }
402289
public function get_name() {
        $identifier = 'cachedef_'.clean_param($this->area, PARAM_STRINGID);
        $component = $this->component;
        if ($component === 'core') {
            $component = 'cache';
        }
        return new lang_string($identifier, $component);
    }
769832
public function getUrl($languageCode = null)
    {
        if ($languageCode && in_array($languageCode, Language::getAllowedLanguages())) {
            return $this->url . '&lang=' . $languageCode;
        }

        return $this->url;
    }
733192
public function get($countryCode)
    {
        if (strlen($countryCode) !== 2) {
            throw new \InvalidArgumentException('Please provide a 2 character country code.');
        }

        $countryCode = strtoupper($countryCode);

        if (array_key_exists($countryCode, $this->aliases)) {
            $countryCode = $this->aliases[$countryCode];
        }

        return implode('', array_map([$this, 'toUnicode'], str_split($countryCode)));
    }
800855
static function idByLocale( $locale )
    {
        $language = eZContentLanguage::fetchByLocale( $locale );
        if ( $language )
        {
            return (int)$language->attribute( 'id' );
        }
        else
        {
            return false;
        }
    }
1194895
public function getByCode($code)
    {
        return $this->languages->filter(
            function ($language) use ($code) {
                return $language->code == $code;
            }
        )->first();
    }
1330363
public function getLanguageByString(
        $code,
        $format = 'iso639_2t',
        $default = null
    ) {
        if (empty($code)) {
            return $default;
        }

        if (!in_array($format, $this->validFormats)) {
            throw new LanguageNotFoundException('Language Format not valid.');
        }

        try {
            $result = $this->findOneBy([$format => $code]);
        } catch (NoResultException $e) {
            $result = $default;
        }

        return $result;
    }
944853
public static function uuid4() : string
    {
        $uuid = Uuid::uuid4();
        $shortUuid = new self();
        return $shortUuid->encode($uuid);
    }
490068
public static function getName($code)
    {
        if (!isset(self::$codesDescriptions[$code])) {
            throw new InvalidArgumentException("Invalid code $code specified");
        }

        return self::$codesDescriptions[$code];
    }
1034719
public function getNativeOfficialName($languageCode = null): ?string
    {
        $languageCode = $languageCode ? mb_strtolower($languageCode) : null;

        return $this->get("name.native.{$languageCode}.official")
            ?: (current($this->get('name.native', []))['official'] ?: $this->get('native_official_name'));
    }
1308745
public static function chr(int $code): string
    {
        if ($code < 0 || ($code >= 0xD800 && $code <= 0xDFFF) || $code > 0x10FFFF) {
            throw new \InvalidArgumentException('Code point must be in range 0x0 to 0xD7FF or 0xE000 to 0x10FFFF.');
        }

        if (\function_exists('\mb_chr')) {
            return \mb_chr($code);
        }

        if (\function_exists('\iconv')) {
            return \iconv('UTF-32BE', 'UTF-8//IGNORE', \pack('N', $code));
        }

        if (0x80 > $code %= 0x200000) {
            return \chr($code);
        }
        if (0x800 > $code) {
            return \chr(0xC0 | $code >> 6) . \chr(0x80 | $code & 0x3F);
        }
        if (0x10000 > $code) {
            return \chr(0xE0 | $code >> 12) . \chr(0x80 | $code >> 6 & 0x3F) . \chr(0x80 | $code & 0x3F);
        }

        return \chr(0xF0 | $code >> 18) . \chr(0x80 | $code >> 12 & 0x3F) . \chr(0x80 | $code >> 6 & 0x3F) . \chr(0x80 | $code & 0x3F);
    }
1105190
public static function countryLocaleCode($countryCode)
    {
        $countryLocaleCodes = static::countryLocaleCodes($countryCode);
        if ($languageCode = Language::countryLanguageCode($countryCode)) {
            $languageLocaleCodes = static::languageLocaleCodes($languageCode);
            if ($localeCodes = array_intersect($languageLocaleCodes, $countryLocaleCodes)) {
                return reset($localeCodes);
            } elseif ($countryLocaleCodes) {
                return reset($countryLocaleCodes);
            } elseif ($languageLocaleCodes) {
                return reset($languageLocaleCodes);
            }

            return \Locale::composeLocale([
                'language' => $languageCode,
                'region' => $countryCode,
            ]);
        }

        if (!count($countryLocaleCodes)) {
            return null;
        } elseif (count($countryLocaleCodes) == 1) {
            return reset($countryLocaleCodes);
        }

        if ($localeCode = static::findMainCode($countryLocaleCodes)) {
            return $localeCode;
        }

        foreach ($countryLocaleCodes as $localeCode) {
            $languageCode = static::languageCode($localeCode);
            if (!strcasecmp($languageCode, $countryCode)) {
                return $localeCode;
            }
        }

        return reset($countryLocaleCodes);
    }
312220
public function getCurrencyIdByCode($code) {
        $this->sError = FALSE;

        if ($this->_currencyCode2Id === FALSE) {
            $this->_loadCurrencyCodes();
        }

        if (!isset($this->_currencyCode2Id[$code])) {
            $this->sError = 'Incorect currency code: ' . $code;
            return FALSE;
        }

        return $this->_currencyCode2Id[$code];
    }