Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14001161
D11121.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.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->getCleanTranslations());
}
$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->getCleanTranslations());
}
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,32 @@
abstract public function getName();
abstract public function getTranslations();
+
+ /**
+ * Return the cleaned translation array.
+ *
+ * @return dict<string, wild> Translation map with empty translations removed.
+ */
+ public function getCleanTranslations() {
+ return $this->clean($this->getTranslations());
+ }
+
+
+ /**
+ * Removes NULL-valued translation keys from the translation map, to prevent
+ * echoing out empty strings.
+ *
+ * @param dict<string, wild> Translation map, with empty translations.
+ * @return dict<string, wild> Map with empty translations removed.
+ */
+ protected function clean(array $translation_array) {
+ foreach ($translation_array as $key => $translation_string) {
+ if ($translation_string === null) {
+ unset($translation_array[$key]);
+ }
+ }
+
+ return $translation_array;
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 26, 4:43 AM (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6745363
Default Alt Text
D11121.diff (2 KB)
Attached To
Mode
D11121: Allow PhutilTranslator::translate() to return defaults
Attached
Detach File
Event Timeline
Log In to Comment