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; + } + }