* with the current language, and reset the language later. */
Horde_Nls::setLanguageEnvironment($GLOBALS['language'], $app);
- /* Import this application's configuration values. */
- $this->importConfig($app);
-
- /* Load preferences after the configuration has been loaded to make
- * sure the prefs file has all the information it needs. */
- $this->loadPrefs($app);
-
- /* Reset the language in case there is a different one selected in the
- * preferences. */
- $language = '';
- if (isset($GLOBALS['prefs'])) {
- $language = $GLOBALS['prefs']->getValue('language');
- if ($language != $GLOBALS['language']) {
- Horde_Nls::setLanguageEnvironment($language, $app);
- }
- }
+ /* Load config and prefs and set proper language from the prefs. */
+ $this->_onAppSwitch($app);
/* Call post-push hook. */
try {
* and set the gettext domain and the preferred language. */
$app = $this->getApp();
if ($app) {
- $this->importConfig($app);
- $this->loadPrefs($app);
- $language = $GLOBALS['prefs']->getValue('language');
- Horde_Nls::setLanguageEnvironment($language, $app);
+ $this->_onAppSwitch($app);
}
return $previous;
}
/**
+ * Code to run when switching to an application.
+ *
+ * @param string $app The application name.
+ *
+ * @throws Horde_Exception
+ */
+ protected function _onAppSwitch($app)
+ {
+ /* Import this application's configuration values. */
+ $this->importConfig($app);
+
+ /* Load preferences after the configuration has been loaded to make
+ * sure the prefs file has all the information it needs. */
+ $this->loadPrefs($app);
+
+ /* Reset the language in case there is a different one selected in the
+ * preferences. */
+ $language = $GLOBALS['prefs']->getValue('language');
+ if ($language != $GLOBALS['language']) {
+ Horde_Nls::setLanguageEnvironment($language, $app);
+ }
+ }
+
+ /**
* Return the current application - the app at the top of the application
* stack.
*