|
@@ -35,6 +35,9 @@ class Translation {
|
|
|
$this->currentLanguage = $_GET['lang'];
|
|
$this->currentLanguage = $_GET['lang'];
|
|
|
$_SESSION['language'] = $this->currentLanguage;
|
|
$_SESSION['language'] = $this->currentLanguage;
|
|
|
|
|
|
|
|
|
|
+ // Load translations for the new language immediately
|
|
|
|
|
+ $this->loadTranslations();
|
|
|
|
|
+
|
|
|
// Redirect to same page without language parameter to apply new language
|
|
// Redirect to same page without language parameter to apply new language
|
|
|
$currentUrl = $_SERVER['REQUEST_URI'];
|
|
$currentUrl = $_SERVER['REQUEST_URI'];
|
|
|
$parsedUrl = parse_url($currentUrl);
|
|
$parsedUrl = parse_url($currentUrl);
|
|
@@ -50,9 +53,13 @@ class Translation {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Redirect to clean URL
|
|
|
|
|
- header('Location: ' . $redirectUrl);
|
|
|
|
|
- exit;
|
|
|
|
|
|
|
+ // Only redirect if not in CLI mode to avoid issues during testing
|
|
|
|
|
+ if (php_sapi_name() !== 'cli') {
|
|
|
|
|
+ // Redirect to clean URL
|
|
|
|
|
+ header('Location: ' . $redirectUrl);
|
|
|
|
|
+ exit;
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Check browser language preference
|
|
// Check browser language preference
|
|
@@ -65,14 +72,14 @@ class Translation {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Check configuration default
|
|
|
|
|
- if (defined('DEFAULT_LANGUAGE') && isset($this->supportedLanguages[DEFAULT_LANGUAGE])) {
|
|
|
|
|
|
|
+ // Check configuration default (but prefer English for public site)
|
|
|
|
|
+ if (defined('DEFAULT_LANGUAGE') && isset($this->supportedLanguages[DEFAULT_LANGUAGE]) && DEFAULT_LANGUAGE !== 'fi') {
|
|
|
$this->currentLanguage = DEFAULT_LANGUAGE;
|
|
$this->currentLanguage = DEFAULT_LANGUAGE;
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Fall back to default language
|
|
|
|
|
- $this->currentLanguage = $this->defaultLanguage;
|
|
|
|
|
|
|
+ // Fall back to English as default language
|
|
|
|
|
+ $this->currentLanguage = 'en';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private function loadTranslations() {
|
|
private function loadTranslations() {
|