Return the current instance

@param array $arrAccepted All accepted languages
@param string $strDefault Default language code
@return Localizer
424197
public static function getInstance($arrAccepted=array(), $strDefault='de') {
		if (self::$instance === NULL)
			self::$instance = new self($arrAccepted, $strDefault);
		return self::$instance;
	}
174716
public function getTranslation($allowCreate = false)
    {
        $locales = $this->getLocales();

        if (empty($locales)) {
            throw new LocaleNotFoundException();
        }

        $translation = null;

        foreach ($locales as $locale) {
            if (($translation = $this->translations->get($locale)) !== null) {
                break;
            }
        }

        if ($translation === null && $allowCreate) {
            $translation = $this->getTranslationFactory()->create(['locale' => reset($locales)]);
            $this->addTranslation($translation);
        }

        if ($translation === null && $this->hasFallbackLocale()) {
            $translation = $this->translations->get($this->getFallbackLocale());
        }

        if ($translation === null) {
            if ($this->hasFallbackLocale()) {
                $locales[] = $this->getFallbackLocale();
            }

            throw new TranslationNotFoundException();
        }

        return $translation;
    }
835251
public function init($arrAccepted, $strDefault, $bolStore=true) {
		$strLang = isset($_GET['lang']) ? $_GET['lang']
				: (isset($_SESSION['lang']) ? $_SESSION['lang']
				: (isset($_COOKIE['lang']) ? $_COOKIE['lang'] : false));
		if (!$strLang || !in_array($strLang, $arrAccepted)) {
			$browser = self::askBrowser($arrAccepted, $strDefault);
			$strLang = $browser['lang'];
		}
		if ($bolStore) {
			$_SESSION['lang'] = $strLang;
			setcookie('lang', $strLang, time() + 315885600);
		}
		$this->strCurrent = $strLang;
		return $strLang;
	}
3262
public function getLocale() {
		if($this->locale === null)
			$this->locale = $this->getDefinition()->getEntityManager()->getDefaultLocale();
		return $this->locale;
	}
569503
public Locale getLocaleOrDefault(RouteContext routeContext) {
        String language = getLanguageOrDefault(routeContext);
        return Locale.forLanguageTag(language);
    }
182954
protected function ensureImage($uuidImage, $strDefault)
    {
        $imagePath = ToolboxFile::convertValueToPath($uuidImage);
        if (\strlen($imagePath) && \file_exists(TL_ROOT . '/' . $imagePath)) {
            return $imagePath;
        }

        return $strDefault;
    }
120501
public static function getDefaultTranslator()
    {
        if (null === self::$_defaultTranslator) {
            require_once 'Zend/Registry.php';
            if (Zend_Registry::isRegistered('Zend_Translate')) {
                $translator = Zend_Registry::get('Zend_Translate');
                if ($translator instanceof Zend_Translate_Adapter) {
                    return $translator;
                } elseif ($translator instanceof Zend_Translate) {
                    return $translator->getAdapter();
                }
            }
        }

        return self::$_defaultTranslator;
    }
80366
protected function getGlobalAreaStackObject($c = false)
    {
        if (!$c) {
            $c = Page::getCurrentPage();
        }
        $cp = new Permissions($c);
        $contentSource = Stack::MULTILINGUAL_CONTENT_SOURCE_CURRENT;
        if ($this->ignoreCurrentMultilingualLanguageSection) {
            $contentSource = Stack::MULTILINGUAL_CONTENT_SOURCE_DEFAULT;
        }
        if ($cp->canViewPageVersions()) {
            $stack = Stack::getByName($this->arHandle, 'RECENT', null, $contentSource);
        } else {
            $stack = Stack::getByName($this->arHandle, 'ACTIVE', null, $contentSource);
        }

        return $stack;
    }
58462
public function detect(string $str): LanguageResult
    {
        $str = mb_strtolower($str);

        $samples = $this->getNgrams($str);

        $result = [];

        if (count($samples) > 0)
        {
            foreach ($this->tokens as $lang => $value)
            {
                $index = $sum = 0;
                $value = array_flip($value);

                foreach ($samples as $v)
                {
                    if (isset($value[$v]))
                    {
                        $x = $index++ - $value[$v];
                        $y = $x >> (PHP_INT_SIZE * 8);
                        $sum += ($x + $y) ^ $y;
                        continue;
                    }

                    $sum += $this->maxNgrams;
                    ++$index;
                }

                $result[$lang] = 1 - ($sum / ($this->maxNgrams * $index));
            }

            arsort($result, SORT_NUMERIC);
        }

        return new LanguageResult($result);
    }
877864
public static function getDefault()
    {
        if ((self::$compatibilityMode === true) or (func_num_args() > 0)) {
            if (!self::$_breakChain) {
                self::$_breakChain = true;
                trigger_error('You are running Zend_Locale in compatibility mode... please migrate your scripts', E_USER_NOTICE);
                $params = func_get_args();
                $param = null;
                if (isset($params[0])) {
                    $param = $params[0];
                }
                return self::getOrder($param);
            }

            self::$_breakChain = false;
        }

        return self::$_default;
    }
1328398
public static function getInstance($lang, $debug = false)
	{
		if (!isset(self::$languages[$lang . $debug]))
		{
			$language = new self($lang, $debug);

			self::$languages[$lang . $debug] = $language;

			// Check if Language was instantiated with a null $lang param;
			// if so, retrieve the language code from the object and store
			// the instance with the language code as well
			if (is_null($lang))
			{
				self::$languages[$language->getLanguage() . $debug] = $language;
			}
		}

		return self::$languages[$lang . $debug];
	}
504877
public function getDefault()
    {
        $sDefault  = $this->oCi->config->item('languages_default');
        $oLanguage = $this->getByCode($sDefault);

        return !empty($oLanguage) ? $oLanguage : false;
    }
827213
public function getCurrentLocale()
    {
        if (is_null($this->currentLocale)) {
            $this->setCurrentLocaleByContext();

            if (!is_admin() || Router::isFrontendAjax()) {
                $this->applyLocale();
            }
        }

        return $this->currentLocale;
    }
1165612
public function getCurrentLocale()
    {
        if ( ! is_null($this->currentLocale))
            return $this->currentLocale;

        if ($this->useAcceptLanguageHeader())
            return $this->negotiateLocale();

        // Get application default language
        return $this->getDefaultLocale();
    }
1374485
public function getLanguageLocale($separator = '-')
    {
        if (!is_array($this->languages)) {
            LanguageDetector::detect($this, $this->getAcceptLanguage());
        }

        $userLanguage = $this->getLanguage();
        foreach ($this->languages as $language) {
            if (strlen($language) === 5 && strpos($language, $userLanguage) === 0) {
                $locale = substr($language, -2);
                break;
            }
        }

        if (!empty($locale)) {
            return $userLanguage . $separator . strtoupper($locale);
        } else {
            return $userLanguage;
        }
    }
453234
public function getLocale()
    {
        // Use the intl extension if present.
        if (class_exists('\Locale')) {
            $locale = \Locale::acceptFromHttp(@$_SERVER['HTTP_ACCEPT_LANGUAGE']);
        }

        // If no locale was obtained, resort to the default one.
        if (empty($locale)) {
            $locale = Application::getSettings()->locale->default;
        }

        return $locale;
    }
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;
    }