Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
[concrete5] How to switch area name based on the current language. Install: upload multilingual_text.php to /helpers directory. Requires Internationalization add-on
<?php defined('C5_EXECUTE') or die("Access Denied.");
Loader::model('section', 'multilingual');
class MultilingualTextHelper {
* Takes area name string (like Header) and add language string (like Header Ja JP)
* @param string $text
* @return string
public function getMultilingualAreaName($text) {
$th = Loader::helper('text');
$ms = MultilingualSection::getCurrentSection();
if (is_object($ms)) {
$locale = $ms->getLocale();
} else {
$locale = Localization::activeLocale();
if ($locale != 'en_US'){
return $text . ' ' . $th->unhandle($locale);
} else {
return $text;
$mt = Loader::helper('multilingual_text');
// 'Global Nav' in English page, 'Global Nav Ja JP' in Japanese page
$a = new GlobalArea($mt->getMultilingualAreaName('Global Nav'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment