src/Charcoal/Cms/Route/GenericRoute.php
protected function setLocale($langCode)
    {
        $translator = $this->translator();
        $translator->setLocale($langCode);

        $available = $translator->locales();
        $fallbacks = $translator->getFallbackLocales();

        array_unshift($fallbacks, $langCode);
        $fallbacks = array_unique($fallbacks);

        $locales = [];
        foreach ($fallbacks as $code) {
            if (isset($available[$code])) {
                $locale = $available[$code];
                if (isset($locale['locales'])) {
                    $choices = (array)$locale['locales'];
                    array_push($locales, ...$choices);
                } elseif (isset($locale['locale'])) {
                    array_push($locales, $locale['locale']);
                }
            }
        }

        $locales = array_unique($locales);

        if ($locales) {
            setlocale(LC_ALL, $locales);
        }
    }
protected function setLocale($langCode)
    {
        $translator = $this->translator();
        $translator->setLocale($langCode);

        $available = $translator->locales();
        $fallbacks = $translator->getFallbackLocales();

        array_unshift($fallbacks, $langCode);
        $fallbacks = array_unique($fallbacks);

        $locales = [];
        foreach ($fallbacks as $code) {
            if (isset($available[$code])) {
                $locale = $available[$code];
                if (isset($locale['locales'])) {
                    $choices = (array)$locale['locales'];
                    array_push($locales, ...$choices);
                } elseif (isset($locale['locale'])) {
                    array_push($locales, $locale['locale']);
                }
            }
        }

        $locales = array_unique($locales);

        if ($locales) {
            setlocale(LC_ALL, $locales);
        }
    }
protected function setLocale ( $ langCode ) { $ translator = $ this -> translator ( ) ; $ translator -> setLocale ( $ langCode ) ; $ available = $ translator -> locales ( ) ; $ fallbacks = $ translator -> getFallbackLocales ( ) ; array_unshift ( $ fallbacks , $ langCode ) ; $ fallbacks = array_unique ( $ fallbacks ) ; $ locales = [ ] ; foreach ( $ fallbacks as $ code ) { if ( isset ( $ available [ $ code ] ) ) { $ locale = $ available [ $ code ] ; if ( isset ( $ locale [ 'locales' ] ) ) { $ choices = ( array ) $ locale [ 'locales' ] ; array_push ( $ locales , ... $ choices ) ; } elseif ( isset ( $ locale [ 'locale' ] ) ) { array_push ( $ locales , $ locale [ 'locale' ] ) ; } } } $ locales = array_unique ( $ locales ) ; if ( $ locales ) { setlocale ( LC_ALL , $ locales ) ; } }
Sets the environment's current locale.

@param  string $langCode The locale's language code.
@return void
Sets the environment s current locale .