Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15469891
D11121.id26711.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D11121.id26711.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D11121: Allow PhutilTranslator::translate() to return defaults
Attached
Detach File
Event Timeline
Log In to Comment