From dc0544c12767ca6f2d1679c87c3e94f0bc9982ff Mon Sep 17 00:00:00 2001
From: Thomas Steur <thomas.steur@googlemail.com>
Date: Mon, 25 Aug 2014 10:10:43 +0200
Subject: [PATCH] refs #5863 we need to pass the langCode to
 loadPluginTranslations() otherwise langCode will be always an empty string.
 If there is no plugin loaded yet and no language generate a simple cache file
 for core translations, load a translation only if a langCode is there

---
 core/FrontController.php |  2 +-
 core/Plugin/Manager.php  | 20 ++++++++++++++++----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/core/FrontController.php b/core/FrontController.php
index 8a8949ad2c..3c1fb601ce 100644
--- a/core/FrontController.php
+++ b/core/FrontController.php
@@ -313,7 +313,7 @@ class FrontController extends Singleton
             Filechecks::dieIfDirectoriesNotWritable($directoriesToCheck);
 
             Translate::loadEnglishTranslation();
-            Plugin\Manager::getInstance()->loadPluginTranslations();
+            Plugin\Manager::getInstance()->loadPluginTranslations('en');
 
             $exceptionToThrow = self::createConfigObject();
 
diff --git a/core/Plugin/Manager.php b/core/Plugin/Manager.php
index 17c056cba6..6a9537df1f 100644
--- a/core/Plugin/Manager.php
+++ b/core/Plugin/Manager.php
@@ -650,9 +650,18 @@ class Manager extends Singleton
             $language = Translate::getLanguageToLoad();
         }
 
-        $cache        = new CacheFile('tracker', 43200); // ttl=12hours
-        $cacheKey     = 'PluginTranslations-' . $language;
-        $cacheKey    .= '-' . md5(implode('', $this->getLoadedPluginsName())); // makes sure to create a translation in case loaded plugins change (ie Tests vs Tracker vs UI etc)
+        $cache    = new CacheFile('tracker', 43200); // ttl=12hours
+        $cacheKey = 'PluginTranslations';
+
+        if (!empty($language)) {
+            $cacheKey .= '-' . trim($language);
+        }
+
+        if (!empty($this->loadedPlugins)) {
+            // makes sure to create a translation in case loaded plugins change (ie Tests vs Tracker vs UI etc)
+            $cacheKey .= '-' . md5(implode('', $this->getLoadedPluginsName()));
+        }
+
         $translations = $cache->get($cacheKey);
 
         if (!empty($translations) &&
@@ -1015,7 +1024,10 @@ class Manager extends Singleton
         }
 
         // merge in specific language translations (to overwrite english defaults)
-        if ($defaultEnglishLangPath != $defaultLangPath && file_exists($defaultLangPath)) {
+        if (!empty($langCode) &&
+            $defaultEnglishLangPath != $defaultLangPath &&
+            file_exists($defaultLangPath)) {
+
             $translations = $this->getTranslationsFromFile($defaultLangPath);
             $translationsLoaded = true;
             if (isset($translations[$pluginName])) {
-- 
GitLab