Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set ACTIVE_LOCALE depending on the current page #39

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/multilingual/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ public function getPackageDescription() {
public function getPackageName() {
return t('Internationalization');
}


public function warmUp() {
if(!defined('ACTIVE_LOCALE')) {
$locale = Loader::helper('section', 'multilingual')->getLocale(false);
if(is_string($locale) && strlen($locale)) {
define('ACTIVE_LOCALE', $locale);
}
}
}

public function on_start() {
define('DIRNAME_IMAGES_LANGUAGES', 'flags');
if(!defined('MULTILINGUAL_FLAGS_WIDTH')) {
Expand Down
6 changes: 4 additions & 2 deletions packages/multilingual/helpers/section.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ public function isRtlLocale() {
* based first on path within the site (section) or session if not available
* @return string
*/
public function getLocale() {
public function getLocale($setDefaultLocale = true) {
$ms = MultilingualSection::getCurrentSection();
if (is_object($ms)) {
$lang = $ms->getLocale();
} else {
$lang = Loader::helper('default_language','multilingual')->getSessionDefaultLocale();
}
$_SESSION['DEFAULT_LOCALE'] = (string) $lang;
if($setDefaultLocale) {
$_SESSION['DEFAULT_LOCALE'] = (string) $lang;
}
return (string) $lang;
}
}