Page MenuHomePhabricator

D11121.id26711.diff
No OneTemporary

D11121.id26711.diff

diff --git a/src/applications/base/controller/PhabricatorController.php b/src/applications/base/controller/PhabricatorController.php
--- a/src/applications/base/controller/PhabricatorController.php
+++ b/src/applications/base/controller/PhabricatorController.php
@@ -102,7 +102,7 @@
$translation = newv($translation, array());
PhutilTranslator::getInstance()
->setLanguage($translation->getLanguage())
- ->addTranslations($translation->getTranslations());
+ ->addTranslations($translation->getCleanTranslation());
}
$preferences = $user->loadPreferences();
diff --git a/src/infrastructure/env/PhabricatorEnv.php b/src/infrastructure/env/PhabricatorEnv.php
--- a/src/infrastructure/env/PhabricatorEnv.php
+++ b/src/infrastructure/env/PhabricatorEnv.php
@@ -117,7 +117,7 @@
$translation = PhabricatorEnv::newObjectFromConfig('translation.provider');
PhutilTranslator::getInstance()
->setLanguage($translation->getLanguage())
- ->addTranslations($translation->getTranslations());
+ ->addTranslations($translation->getCleanTranslation());
}
private static function buildConfigurationSourceStack() {
diff --git a/src/infrastructure/internationalization/translation/PhabricatorTranslation.php b/src/infrastructure/internationalization/translation/PhabricatorTranslation.php
--- a/src/infrastructure/internationalization/translation/PhabricatorTranslation.php
+++ b/src/infrastructure/internationalization/translation/PhabricatorTranslation.php
@@ -6,4 +6,30 @@
abstract public function getName();
abstract public function getTranslations();
+ /**
+ * Return the cleand translation array
+ *
+ * @return array
+ */
+ public function getCleanTranslation() {
+ return $this->clean($this->getTranslations());
+ }
+
+ /**
+ * Removes NULL values translation key from the translation to prevent
+ * echoing out empty strings.
+ *
+ * @param array $translationArray the translation array to be cleaned
+ * @return mixed
+ */
+ protected function clean($translationArray) {
+ foreach($translationArray as $key => $translationString) {
+ if($translationString === NULL) {
+ unset($translationArray[$key]);
+ }
+ }
+
+ return $translationArray;
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 5, 5:49 PM (8 h, 44 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7386833
Default Alt Text
D11121.id26711.diff (2 KB)

Event Timeline