Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14127281
D7532.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
D7532.diff
View Options
Index: src/internationalization/PhutilTranslator.php
===================================================================
--- src/internationalization/PhutilTranslator.php
+++ src/internationalization/PhutilTranslator.php
@@ -68,6 +68,12 @@
}
array_shift($args);
+ foreach ($args as $k => $arg) {
+ if ($arg instanceof PhutilNumber) {
+ $args[$k] = $this->formatNumber($arg->getNumber(), $arg->getDecimals());
+ }
+ }
+
// Check if any arguments are PhutilSafeHTML. If they are, we will apply
// any escaping necessary and output HTML.
$is_html = false;
@@ -84,12 +90,6 @@
}
}
- foreach ($args as $k => $arg) {
- if ($arg instanceof PhutilNumber) {
- $args[$k] = $this->formatNumber($arg->getNumber(), $arg->getDecimals());
- }
- }
-
$result = vsprintf($translation, $args);
if ($this->language == 'en-ac') {
@@ -178,7 +178,7 @@
/**
* Format number with grouped thousands and optional decimal part. Requires
* translations of '.' (decimal point) and ',' (thousands separator). Both
- * these translations must be 1 byte long.
+ * these translations must be 1 byte long with PHP < 5.4.0.
*
* @param float
* @param int
Index: src/internationalization/__tests__/PhutilTranslatorTestCase.php
===================================================================
--- src/internationalization/__tests__/PhutilTranslatorTestCase.php
+++ src/internationalization/__tests__/PhutilTranslatorTestCase.php
@@ -220,8 +220,8 @@
$who,
$when);
$this->assertEqual(
- true,
- gettype($translation) == 'string');
+ 'string',
+ gettype($translation));
$this->assertEqual(
'<span>Abraham</span> awoke <strong>suddenly</strong> at <4 AM>.',
$translation);
@@ -238,6 +238,14 @@
$this->assertEqual(
'<span>Abraham</span> awoke <strong>suddenly</strong> at <4 AM>.',
$translation->getHTMLContent());
+
+ $translation = $translator->translate(
+ $string,
+ $who,
+ new PhutilNumber(1383930802));
+ $this->assertEqual(
+ '<span>Abraham</span> awoke <strong>suddenly</strong> at 1,383,930,802.',
+ $translation->getHTMLContent());
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 1, 8:32 PM (19 h, 47 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6813723
Default Alt Text
D7532.diff (2 KB)
Attached To
Mode
D7532: Allow using numbers and HTML fragments in translations together
Attached
Detach File
Event Timeline
Log In to Comment