This method is intend to read a previous stored locale-configuration from session.

@author Benjamin Carl <opensource@clickalicious.de>

@return mixed ARRAY with locale-settings if previously stored in session, otherwise NULL
347751
protected function readSession()
    {
        // Assume empty cookie / no stored configuration
        try {
            $storedSettings = $this->getSession()->get(self::$identifier);
        } catch (Doozr_Session_Service_Exception $e) {
            $storedSettings = null;
        }

        // Check the result for validity
        if (!$storedSettings || !$this->isValidLocaleCode($storedSettings['locale'])) {
            $storedSettings = null;
        }

        return $storedSettings;
    }
619438
protected function getCountries()
    {
        $loadedLanguage = $this->getMetaModel()->getActiveLanguage();
        if (isset($this->countryCache[$loadedLanguage])) {
            return $this->countryCache[$loadedLanguage];
        }

        $languageValues = $this->getCountryNames($loadedLanguage);
        $countries      = $this->getRealCountries();
        $keys           = \array_keys($countries);
        $aux            = [];
        $real           = [];

        // Fetch real language values.
        foreach ($keys as $key) {
            if (isset($languageValues[$key])) {
                $aux[$key]  = Utf8::toAscii($languageValues[$key]);
                $real[$key] = $languageValues[$key];
            }
        }

        // Add needed fallback values.
        $keys = \array_diff($keys, \array_keys($aux));
        if ($keys) {
            $loadedLanguage = $this->getMetaModel()->getFallbackLanguage();
            $fallbackValues = $this->getCountryNames($loadedLanguage);
            foreach ($keys as $key) {
                if (isset($fallbackValues[$key])) {
                    $aux[$key]  = Utf8::toAscii($fallbackValues[$key]);
                    $real[$key] = $fallbackValues[$key];
                }
            }
        }

        $keys = \array_diff($keys, \array_keys($aux));
        if ($keys) {
            foreach ($keys as $key) {
                $aux[$key]  = $countries[$key];
                $real[$key] = $countries[$key];
            }
        }

        \asort($aux);
        $return = [];
        foreach (\array_keys($aux) as $key) {
            $return[$key] = $real[$key];
        }

        $this->restoreLanguage();

        $this->countryCache[$loadedLanguage] = $return;

        return $return;
    }
1107442
@Override
    public Locale getLocale() {
        if (null == this.locales) {
            this.locales = connection.getEncodingUtils().getLocales(this.request.getHeader("Accept-Language"));
        }
        if (this.locales.isEmpty()) {
            return null;
        }
        return this.locales.get(0);
    }
454101
@Override
    public Locale getLocale() {
        if (super.getSession(false) == null) {
            return super.getLocale();
        }

        final IUserInstance userInstance =
                this.userInstanceManager.getUserInstance(this.getWrappedRequest());
        final LocaleManager localeManager = userInstance.getLocaleManager();
        final List<Locale> locales = localeManager.getLocales();
        return locales.get(0);
    }
1283487
public function getLocales()
    {
        $this->start();
        try {
            $this->getUserControl()->checkRateLimit();
            $this->getUserControl()->checkGenericAccess(__FUNCTION__);
            $locales = $this->app->make(LocaleRepository::class)->getApprovedLocales();
            $result = $this->buildJsonResponse($this->localesToArray($locales));
        } catch (Exception $x) {
            $result = $this->buildErrorResponse($x);
        } catch (Throwable $x) {
            $result = $this->buildErrorResponse($x);
        }

        return $this->finish($result);
    }
1180238
protected function getDomainLocale()
    {
        $state = FluentState::singleton();

        // Ensure a domain is configured
        if (!$state->getIsDomainMode()) {
            return null;
        }
        $domain = $state->getDomain();
        if (!$domain) {
            return null;
        }

        // Get domain
        $domainObj = Domain::getByDomain($domain);
        if (!$domainObj) {
            return null;
        }

        // If the current domain has exactly one locale, the locale is non-ambiguous
        $locales = Locale::getCached()->filter('DomainID', $domainObj->ID);
        /** @var Locale $localeObject */
        $localeObject = $locales->first();
        if ($localeObject) {
            return $localeObject->getLocale();
        }

        return null;
    }
52296
public function getStoreLanguageMapping() {
    $mapping = [];

    $languages = $this->languageManager->getLanguages();

    // Prepare the alternate locale data.
    foreach ($languages as $lang => $language) {
      // For default language, we access the config directly.
      if ($lang == $this->languageManager->getDefaultLanguage()->getId()) {
        $config = $this->configFactory->get('acm.store');
      }
      // We get store id from translated config for other languages.
      else {
        $config = $this->languageManager->getLanguageConfigOverride($lang, 'acm.store');
      }

      $mapping[$lang] = $config->get('store_id');
    }

    return $mapping;
  }
46954
protected function loadConfiguration()
    {
        $configuration = null;

        if (file_exists(self::CONFIGURATION_FILENAME)) {
            $configuration = json_decode(file_get_contents(self::CONFIGURATION_FILENAME), true);
        }

        return $configuration ?: array();
    }
6768
public function all($locale = null){

        if(!$locale){
            $locale = $this->getLocale();
        }

        $this->load($locale);

        $translations = collect([]);
        foreach($this->languages[$locale] as $key => $arg){
            $translations->put($key, $arg['value']);
        }

        return $translations;
    }
290389
public function getLocale()
	{
		if (!$this->locale) {
            $locale = self::getStaticLocale();
            if (!$locale) {
                $locale = StdLocale::getDefault();
            }

            $this->setLocale($locale);
		}
		
		return $this->locale;
	}
7163
protected function readCookie()
    {
        if (isset($_COOKIE[self::$identifier])) {
            $storedSettings = explode(',', $_COOKIE[self::$identifier]);

            // locale
            if ($this->isValidLocaleCode($storedSettings[0]) &&
                $this->isValidLocaleCode($storedSettings[2]) &&
                $this->isValidLocaleCode($storedSettings[3])
            ) {
                $locale = [
                    'locale'   => $storedSettings[0],
                    'weight'   => (double) $storedSettings[1],
                    'language' => $storedSettings[2],
                    'country'  => $storedSettings[3],
                ];
            } else {
                $locale = null;
            }
        }

        // Return result
        return (isset($locale)) ? $locale : null;
    }
956361
public static function get_locale()
    {
        if (!self::$current_locale) {
            self::$current_locale = i18n::config()->uninherited('default_locale');
        }
        return self::$current_locale;
    }
286240
private function getLocale() : string
  {
    $locale = ($this->locale ?? config('faker.locale.default'));

    if (
      $locale !== null &&
      is_array(config('faker.locale.supported')) &&
      in_array(config('faker.locale.default'), config('faker.locale.supported'))
    ) {
      return $locale;
    }

    return 'en_US';
  }
124360
public static function locale()
    {
        if (!self::isDebug()) {
            return false;
        }

        ob_start();
        @system('locale -a');
        $locale = explode(PHP_EOL, trim(ob_get_contents()));
        ob_end_clean();

        $result = array(
            'list' => $locale,
            'conv' => @localeconv()
        );

        return self::i()->dump($result, '! locale info !');
    }
1111761
public function saveEntityTranslations()
    {
        if (empty($this->translationsBackup)) {
            return null;
        }

        foreach ($this->translationsBackup as $formHash => $entities) {
            foreach ($entities as $entityData) {
                $entity = $entityData['object'];
                $entityIdGetter = $entityData['idGetter'];
                $entityAlias = $entityData['alias'];
                $fields = $entityData['fields'];

                foreach ($fields as $fieldName => $locales) {
                    foreach ($locales as $locale => $translation) {
                        $this
                            ->entityTranslationProvider
                            ->setTranslation(
                                $entityAlias,
                                $entity->$entityIdGetter(),
                                $fieldName,
                                $translation,
                                $locale
                            );
                    }
                }
            }
        }

        $this
            ->entityTranslationProvider
            ->flushTranslations();
    }
1083045
protected function getLocaleChoices()
    {
        $localeChoices = [];

        if (!$this->request) {
            return [];
        }

        if (!$this->getRequest()->get('locale')) {
            $locale = $this->getRequest()->getLocale();
        } else {
            $locale = $this->getRequest()->get('locale');
        }

        if (is_array($locale) && array_key_exists('value', $locale)) {
            $locale = $locale['value'];
        }

        $localeList = Intl::getLocaleBundle()->getLocaleNames(substr($locale, 0, 2));

        foreach ($this->languages as $language) {
            $localeChoices[$localeList[$language['locale']]] = $language['locale'];
        }

        return $localeChoices;
    }
1038272
private function checkLocaleSet() {
		
		if (!$this->defaultLocale) {
			
			$locale = Locale::getDefault();
			$this->defaultLocale = $locale;
			
			// server variable
			setlocale(LC_ALL, $locale->getRepresentation());
			
		}
		
		if (!$this->currentLocale) {
			
			// temporary sets default locale as current
			$this->currentLocale = $this->defaultLocale;
			
			// gets favorite language from browser settings
			if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
			
				preg_match_all('/([[:alpha:]]{1,8})(-([[:alpha:]|-]{1,8}))?' .
						'(\s*;\s*q\s*=\s*(1\.0{0,3}|0\.\d{0,3}))?\s*(,|$)/i',
						$_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches, PREG_SET_ORDER);
			
				// if browser’s lang matches and it’s different by current, will set as current
				if (!isset($matches[0][1]) or $this->currentLocale->getLanguage()->code == $matches[0][1]) {
					return;
				}
				
				$locale = Locale::getDefaultByLanguage($matches[0][1]);
				if (!$locale) {
					return;
				}
				
				$this->setLocale($locale);
					
			}

		}
		
	}