concrete/src/Multilingual/Service/Detector.php
public function setupSiteInterfaceLocalization(Page $c = null)
    {
        $app = Facade::getFacadeApplication();
        $loc = $app->make(Localization::class);
        $locale = null;
        if ($c === null) {
            $c = Page::getCurrentPage();
        }
        if ($c) {
            $pageController = $c->getPageController();
            if (is_callable([$pageController, 'useUserLocale'])) {
                $useUserLocale = $pageController->useUserLocale();
            } else {
                $dh = $app->make('helper/concrete/dashboard');
                $useUserLocale = $dh->inDashboard($c);
            }
            if ($useUserLocale) {
                $u = new User();
                $locale = $u->getUserLanguageToDisplay();
            } else {
                if ($this->isEnabled()) {
                    $ms = Section::getBySectionOfSite($c);
                    if (!$ms) {
                        $ms = static::getPreferredSection();
                    }
                    if ($ms) {
                        $locale = $ms->getLocale();

                        if ($this->canSetSessionValue()) {
                            $app->make('session')->set('multilingual_default_locale', $locale);
                        }
                    }
                }
                if (!$locale) {
                    $siteTree = $c->getSiteTreeObject();
                    if ($siteTree) {
                        $locale = $siteTree->getLocale()->getLocale();
                    }
                }
            }
        }
        if (!$locale) {
            $locale = $app->make('config')->get('concrete.locale');
        }
        $loc->setContextLocale(Localization::CONTEXT_SITE, $locale);
    }
public function setupSiteInterfaceLocalization(Page $c = null)
    {
        $app = Facade::getFacadeApplication();
        $loc = $app->make(Localization::class);
        $locale = null;
        if ($c === null) {
            $c = Page::getCurrentPage();
        }
        if ($c) {
            $pageController = $c->getPageController();
            if (is_callable([$pageController, 'useUserLocale'])) {
                $useUserLocale = $pageController->useUserLocale();
            } else {
                $dh = $app->make('helper/concrete/dashboard');
                $useUserLocale = $dh->inDashboard($c);
            }
            if ($useUserLocale) {
                $u = new User();
                $locale = $u->getUserLanguageToDisplay();
            } else {
                if ($this->isEnabled()) {
                    $ms = Section::getBySectionOfSite($c);
                    if (!$ms) {
                        $ms = static::getPreferredSection();
                    }
                    if ($ms) {
                        $locale = $ms->getLocale();

                        if ($this->canSetSessionValue()) {
                            $app->make('session')->set('multilingual_default_locale', $locale);
                        }
                    }
                }
                if (!$locale) {
                    $siteTree = $c->getSiteTreeObject();
                    if ($siteTree) {
                        $locale = $siteTree->getLocale()->getLocale();
                    }
                }
            }
        }
        if (!$locale) {
            $locale = $app->make('config')->get('concrete.locale');
        }
        $loc->setContextLocale(Localization::CONTEXT_SITE, $locale);
    }
public function setupSiteInterfaceLocalization ( Page $ c = null ) { $ app = Facade :: getFacadeApplication ( ) ; $ loc = $ app -> make ( Localization :: class ) ; $ locale = null ; if ( $ c === null ) { $ c = Page :: getCurrentPage ( ) ; } if ( $ c ) { $ pageController = $ c -> getPageController ( ) ; if ( is_callable ( [ $ pageController , 'useUserLocale' ] ) ) { $ useUserLocale = $ pageController -> useUserLocale ( ) ; } else { $ dh = $ app -> make ( 'helper/concrete/dashboard' ) ; $ useUserLocale = $ dh -> inDashboard ( $ c ) ; } if ( $ useUserLocale ) { $ u = new User ( ) ; $ locale = $ u -> getUserLanguageToDisplay ( ) ; } else { if ( $ this -> isEnabled ( ) ) { $ ms = Section :: getBySectionOfSite ( $ c ) ; if ( ! $ ms ) { $ ms = static :: getPreferredSection ( ) ; } if ( $ ms ) { $ locale = $ ms -> getLocale ( ) ; if ( $ this -> canSetSessionValue ( ) ) { $ app -> make ( 'session' ) -> set ( 'multilingual_default_locale' , $ locale ) ; } } } if ( ! $ locale ) { $ siteTree = $ c -> getSiteTreeObject ( ) ; if ( $ siteTree ) { $ locale = $ siteTree -> getLocale ( ) -> getLocale ( ) ; } } } } if ( ! $ locale ) { $ locale = $ app -> make ( 'config' ) -> get ( 'concrete.locale' ) ; } $ loc -> setContextLocale ( Localization :: CONTEXT_SITE , $ locale ) ; }
Set the locale associated to the 'site' localization context.

@param Page $c The page to be used to determine the site locale (if null we'll use the current page)
Set the locale associated to the site localization context .