How to get the site locale in Concrete 5

07, February 2022

This is how you get the site locale in Concrete 5

In the controller

$site = $this->app->make('site')->getSite();
$defaultLocale = $site->getDefaultLocale();
$defaultLocaleCode = $defaultLocale->getLocale();
// This sets the variable so you can access it in the view
$this->set('defaultLocaleCode', $defaultLocaleCode);

In the view

var_dump($defaultLocaleCode); // en_GB
Peter Fisher Contract Web Developer

Peter Fisher is a UK based PHP contractor with 20 years experience in web development He can be hired to work with PHP using Symfony or Laravel or Flask and Django with Python.