From ff8e583c2269aedbb94b4be71ad8093f7760241a Mon Sep 17 00:00:00 2001 From: sgiehl <stefan@piwik.org> Date: Sun, 12 Jan 2014 00:08:38 +0100 Subject: [PATCH] fixed translation issue with plugins; plugin default translations (en), were not loaded if a translation file for a specific language exists --- core/Plugin/Manager.php | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/core/Plugin/Manager.php b/core/Plugin/Manager.php index 34e69c0ec2..dec9921093 100644 --- a/core/Plugin/Manager.php +++ b/core/Plugin/Manager.php @@ -841,19 +841,29 @@ class Manager extends Singleton $defaultLangPath = sprintf($path, $langCode); $defaultEnglishLangPath = sprintf($path, 'en'); - if (file_exists($defaultLangPath)) { - $translations = $this->getTranslationsFromFile($defaultLangPath); - } elseif (file_exists($defaultEnglishLangPath)) { + $translationsLoaded = false; + + // merge in english translations as default first + if (file_exists($defaultEnglishLangPath)) { $translations = $this->getTranslationsFromFile($defaultEnglishLangPath); - } else { - return false; + $translationsLoaded = true; + if (isset($translations[$pluginName])) { + // only merge translations of plugin - prevents overwritten strings + Translate::mergeTranslationArray(array($pluginName => $translations[$pluginName])); + } } - if (isset($translations[$pluginName])) { - // only merge translations of plugin - prevents overwritten strings - Translate::mergeTranslationArray(array($pluginName => $translations[$pluginName])); + // merge in specific language translations (to overwrite english defaults) + if (file_exists($defaultLangPath)) { + $translations = $this->getTranslationsFromFile($defaultLangPath); + $translationsLoaded = true; + if (isset($translations[$pluginName])) { + // only merge translations of plugin - prevents overwritten strings + Translate::mergeTranslationArray(array($pluginName => $translations[$pluginName])); + } } - return true; + + return $translationsLoaded; } /** -- GitLab