Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15407370
D7532.id16989.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.id16989.diff
View Options
Index: src/internationalization/PhutilTranslator.php
===================================================================
--- src/internationalization/PhutilTranslator.php
+++ src/internationalization/PhutilTranslator.php
@@ -78,18 +78,18 @@
}
}
- if ($is_html) {
- foreach ($args as $k => $arg) {
- $args[$k] = (string)phutil_escape_html($arg);
- }
- }
-
foreach ($args as $k => $arg) {
if ($arg instanceof PhutilNumber) {
$args[$k] = $this->formatNumber($arg->getNumber(), $arg->getDecimals());
}
}
+ if ($is_html) {
+ foreach ($args as $k => $arg) {
+ $args[$k] = (string)phutil_escape_html($arg);
+ }
+ }
+
$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
Wed, Mar 19, 5:16 PM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7711706
Default Alt Text
D7532.id16989.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