How to get the locale of a page

This is a community-contributed tutorial.
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"
Recent Tutorials
How to change the default date format
May 30, 2024
By myq.

Change the format of the default date

WebOps Tutorial on Running and Upgrading a Concrete CMS Website
May 2, 2024
By myq.

Describes how to deploy, manage, and upgrade a Concrete CMS website

Using the Concrete Migration Tool Addon
Apr 27, 2024

How to use the Concrete CMS Migration Tool

Create custom Site Health tasks
Apr 19, 2024
By myq.

This tutorial will guide you through the creation of a new Site Health task

Reusing the same Express entity in multiple associations
Apr 11, 2024
By myq.

How to create and manage multiple associations in Express

Express Form Styling
Apr 11, 2024
By myq.

Different ways to style Express forms

Improvements?

Let us know by posting here.