Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15465508
D11160.id26780.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D11160.id26780.diff
View Options
diff --git a/src/internationalization/PhutilTranslator.php b/src/internationalization/PhutilTranslator.php
--- a/src/internationalization/PhutilTranslator.php
+++ b/src/internationalization/PhutilTranslator.php
@@ -60,6 +60,11 @@
public function translate($text /* , ... */) {
$translation = idx($this->translations, $text, $text);
+
+ if ($translation === null) {
+ $translation = $text;
+ }
+
$args = func_get_args();
while (is_array($translation)) {
$translation = $this->chooseVariant($translation, next($args));
@@ -89,6 +94,13 @@
}
$result = vsprintf($translation, $args);
+ if ($result === false) {
+ // If vsprintf() fails (often because the translated string references
+ // too many parameters), show the bad template with a note instead of
+ // returning an empty string. This makes it easier to figure out what
+ // went wrong and fix it.
+ $result = '[Invalid Translation!] '.$translation;
+ }
if ($this->language == 'en-ac') {
$result = strtoupper($result);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 3, 7:43 PM (2 w, 18 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7712571
Default Alt Text
D11160.id26780.diff (1 KB)
Attached To
Mode
D11160: When a translated string is bogus, partially recover
Attached
Detach File
Event Timeline
Log In to Comment