How to get the locale of a page
This is a community-contributed tutorial. This tutorial is over a year old and may not apply to your version of Concrete CMS.
Jan 8, 2024
Get the page object if you don't alredy have it $c = \Page::getByPath("/path/to/page", "ACTIVE");
Get the site tree it belongs to $siteTree = \Core::make("site")->getSiteTreeByID($c->getSiteTreeID());
Get the tree's locale object with its methods $pageLocaleObject = $siteTree->getLocale();
Finally, for the juicy details:
- $pageLocale = $siteTree->getLocale()->getLocale(); - "en_GB"
- $pageLanguage = $siteTree->getLocale()->getLanguage(); - "en"
- $pageLanguageText = $siteTree->getLocale()->getLanguageText(); - "English"