Transforms special Language Codes to ISO Codes. To be overwritten.
@access		protected
@param		string		$languageCode	Language Code
@return		string
960452
protected static function transformCode( $languageCode )
	{
		$isoCode	= $languageCode;
		if( $languageCode == "en" || $languageCode == "uk" )
			$isoCode = "gb";
		if( $languageCode == "cs" )
			$isoCode = "cz";
		return $isoCode;
	}
528591
private function cleanUpTimecode($timecode)
    {
        strpos($timecode, ',') ?: $timecode .= ',000';

        $patternNoLeadingZeroes = '/(?:(?<=\:)|^)\d(?=(:|,))/';

        return preg_replace_callback($patternNoLeadingZeroes, function($matches)
        {
            return sprintf('%02d', $matches[0]);
        }, $timecode);
    }
1371599
public static function isValidLangCode($langCode)
    {
        $langList = static::activeLanguagesArray();
        foreach ($langList as $lang) {
            if ($lang['code2'] == $langCode) return true;
            if ($lang['code3'] == $langCode) return true;
            if ($lang['code_full'] == $langCode) return true;
        }
        return false;
    }
670264
public static function validateLanguageCode(string $languageCode = null): string
    {
        // We allow empty languageCode in order to quit asking for more
        if (empty($languageCode)) {
            return '';
        }

        if (!preg_match('/^[a-z][a-z][a-z]-[A-Z][A-Z]$/', $languageCode)) {
            throw new InvalidArgumentException('Language code name is not valid.');
        }

        return $languageCode;
    }
436429
function setCurrentLanguage( $languageCode )
    {
        $this->CurrentLanguage = $languageCode;
        if ( $this->hasContentObject() )
        {
            $this->ContentObject->setCurrentLanguage( $languageCode );
        }
        $this->Name = null;
    }
1067402
public function getActiveTranslation($languageCode)
    {
        return $this->translations->first(function ($translation) use ($languageCode) {
            return $translation->is_active === true && $translation->language_code === $languageCode;
        });
    }
207180
public function offsetGet($langcode)
    {
        $noDefaultVersion = $this->getDefault() !== $langcode
            and ! isset($this->lang[$this->getDefault()][$this->getCategory()]);
        if (!isset($this->lang[$langcode][$this->getCategory()])) {
            if ($this->isFileExistsInSubDir($langcode)) {
                $this->loadFromFileInSubDir($langcode);
            } elseif ($this->isFileExistsWithSuffix($langcode)) {
                $this->loadFromFileWithSuffix($langcode);
            } elseif ($this->isFileExistsWithoutSuffix($langcode)) {
                $this->loadFromFileWithoutSuffix($langcode);
            } elseif ($noDefaultVersion and $this->isFileExistsInSubDir($this->getDefault())) {
                $langcode = $this->getDefault();
                $this->loadFromFileInSubDir($langcode);
            } elseif ($noDefaultVersion and $this->isFileExistsWithSuffix($this->getDefault())) {
                $langcode = $this->getDefault();
                $this->loadFromFileWithSuffix($langcode);
            } elseif ($noDefaultVersion and $this->isFileExistsWithoutSuffix($this->getDefault())) {
                $langcode = $this->getDefault();
                $this->loadFromFileWithoutSuffix($langcode);
            }
        }

        return $this->lang[$langcode][$this->getCategory()];
    }
830984
public function getLanguageNames(array $languageCodes, $locale)
    {
        $apiCall = new ApiCall\GetLanguageNames($languageCodes, $locale);

        return $this->call($apiCall);
    }
655224
public static function get($code)
  {
    if (array_key_exists($code, self::$translations)) {
      return self::$translations[$code];
    }
    return sprintf('[%s]', $code);
  }
1095359
public static function getCurrencySymbol($isocode) {
		return empty(self::$currencySymbols[$isocode])?$isocode:self::$currencySymbols[$isocode];
	}
935374
public function loadLanguage($code) {
        static $languages_seen = array(); // recursion guard

        // abort if we've already loaded it
        if (isset($this->cache[$code])) return;

        // generate filename
        $filename = $this->dir . '/Language/messages/' . $code . '.php';

        // default fallback : may be overwritten by the ensuing include
        $fallback = ($code != 'en') ? 'en' : false;

        // load primary localisation
        if (!file_exists($filename)) {
            // skip the include: will rely solely on fallback
            $filename = $this->dir . '/Language/messages/en.php';
            $cache = array();
        } else {
            include $filename;
            $cache = compact($this->keys);
        }

        // load fallback localisation
        if (!empty($fallback)) {

            // infinite recursion guard
            if (isset($languages_seen[$code])) {
                trigger_error('Circular fallback reference in language ' .
                    $code, E_USER_ERROR);
                $fallback = 'en';
            }
            $language_seen[$code] = true;

            // load the fallback recursively
            $this->loadLanguage($fallback);
            $fallback_cache = $this->cache[$fallback];

            // merge fallback with current language
            foreach ( $this->keys as $key ) {
                if (isset($cache[$key]) && isset($fallback_cache[$key])) {
                    if (isset($this->mergeable_keys_map[$key])) {
                        $cache[$key] = $cache[$key] + $fallback_cache[$key];
                    } elseif (isset($this->mergeable_keys_list[$key])) {
                        $cache[$key] = array_merge( $fallback_cache[$key], $cache[$key] );
                    }
                } else {
                    $cache[$key] = $fallback_cache[$key];
                }
            }

        }

        // save to cache for later retrieval
        $this->cache[$code] = $cache;

        return;
    }
683728
public static function setLanguageForSession($languageCode)
    {
        if (!API::getInstance()->isLanguageAvailable($languageCode)) {
            return false;
        }

        $cookieName = Config::getInstance()->General['language_cookie_name'];
        $cookie = new Cookie($cookieName, 0);
        $cookie->set('language', $languageCode);
        $cookie->setSecure(ProxyHttp::isHttps());
        $cookie->save();
        return true;
    }
287118
public static function toUTF8Character($charCode)
    {
        switch ($charCode) {
            case 0:
                $char = chr(0);
                break;
            case !($charCode & 0xffffff80): // 7 bit
                $char = chr($charCode);
                break;
            case !($charCode & 0xfffff800): // 11 bit
                $char = (
                    chr(0xc0 | (($charCode >> 6) & 0x1f)) .
                    chr(0x80 | ($charCode & 0x3f))
                );
                break;
            case !($charCode & 0xffff0000): // 16 bit
                $char = (
                    chr(0xe0 | (($charCode >> 12) & 0x0f)) .
                    chr(0x80 | (($charCode >> 6) & 0x3f)) .
                    chr(0x80 | ($charCode & 0x3f))
                );
                break;
            case !($charCode & 0xffe00000): // 21 bit
                $char = (
                    chr(0xf0 | (($charCode >> 18) & 0x07)) .
                    chr(0x80 | (($charCode >> 12) & 0x3f)) .
                    chr(0x80 | (($charCode >> 6) & 0x3f)) .
                    chr(0x80 | ($charCode & 0x3f))
                );
                break;
            case !($charCode & 0xfc000000): // 26 bit
                $char = (
                    chr(0xf8 | (($charCode >> 24) & 0x03)) .
                    chr(0x80 | (($charCode >> 18) & 0x3f)) .
                    chr(0x80 | (($charCode >> 12) & 0x3f)) .
                    chr(0x80 | (($charCode >> 6) & 0x3f)) .
                    chr(0x80 | ($charCode & 0x3f))
                );
                break;
            default: // 31 bit
                $char = (
                    chr(0xfc | (($charCode >> 30) & 0x01)) .
                    chr(0x80 | (($charCode >> 24) & 0x3f)) .
                    chr(0x80 | (($charCode >> 18) & 0x3f)) .
                    chr(0x80 | (($charCode >> 12) & 0x3f)) .
                    chr(0x80 | (($charCode >> 6) & 0x3f)) .
                    chr(0x80 | ($charCode & 0x3f))
                );
        }

        return $char;
    }
637280
function translate ($code)
    {
        if (preg_match_all("/<\?_\(\"(.*)\"\)\?>/siU", $code, $matches, PREG_SET_ORDER)) {
            foreach ($matches as $match) {
                if (isset($match[1])) {
                    $code = str_replace($match[0], gettext(stripslashes($match[1])), $code);
                }
            }
        }
        return $code;
    }
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);
    }
1323648
public static function getLangCode2($langCode)
    {
        $langList = static::activeLanguagesArray();
        foreach ($langList as $lang) {
            if ($lang['code3'] == $langCode) return $lang['code2'];
            if ($lang['code_full'] == $langCode) return $lang['code2'];
            if (strtolower($lang['name_en']) == strtolower($langCode)) return $lang['code2'];
            if (strtolower($lang['name_orig']) == strtolower($langCode)) return $lang['code2'];
        }
        return substr($langCode, 0, 2); //?? or return false
    }
1194895
public function getByCode($code)
    {
        return $this->languages->filter(
            function ($language) use ($code) {
                return $language->code == $code;
            }
        )->first();
    }