8000 Updates according to feedback · symfony/symfony@f88153f · GitHub
[go: up one dir, main page]

Skip to content

Commit f88153f

Browse files
committed
Updates according to feedback
1 parent 597a15d commit f88153f

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

src/Symfony/Component/Translation/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CHANGELOG
77
* Started using ICU parent locales as fallback locales.
88
* deprecated `TranslatorInterface` in favor of `Symfony\Contracts\Translation\TranslatorInterface`
99
* deprecated `MessageSelector`, `Interval` and `PluralizationRules`; use `IdentityTranslator` instead
10-
* Added `IntlMessageFormatter` and`FallbackMessageFormatter`
10+
* Added `IntlMessageFormatter` and `FallbackMessageFormatter`
1111

1212
4.1.0
1313
-----

src/Symfony/Component/Translation/Formatter/FallbackFormatter.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
declare(strict_types=1);
13-
1412
namespace Symfony\Component\Translation\Formatter;
1513

1614
use Symfony\Component\Translation\Exception\LogicException;
@@ -73,6 +71,6 @@ public function choiceFormat($message, $number, $locale, array $parameters = arr
7371
return $this->secondFormatter->choiceFormat($message, $number, $locale, $parameters);
7472
}
7573

76-
throw new LogicException(sprintf('The no formatter support plural translations.'));
74+
throw new LogicException(sprintf('No formatters support plural translations.'));
7775
}
7876
}

src/Symfony/Component/Translation/Formatter/IntlMessageFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ public function format($message, $locale, array $parameters = array())
2727
try {
2828
$formatter = new \MessageFormatter($locale, $message);
2929
} catch (\Throwable $e) {
30-
throw new InvalidArgumentException(sprintf('Invalid message format. Reason: %s (error #%d)', intl_get_error_message(), intl_get_error_code()), 0, $e);
30+
throw new InvalidArgumentException(sprintf('Invalid message format (%s, error #%d).', intl_get_error_message(), intl_get_error_code()), 0, $e);
3131
}
3232

3333
$message = $formatter->format($parameters);
3434
if (U_ZERO_ERROR !== $formatter->getErrorCode()) {
35-
throw new InvalidArgumentException(sprintf('Unable to format message. Reason: %s (error #%s)', $formatter->getErrorMessage(), $formatter->getErrorCode()));
35+
throw new InvalidArgumentException(sprintf('Unable to format message ( %s, error #%s).', $formatter->getErrorMessage(), $formatter->getErrorCode()));
3636
}
3737

3838
return $message;

src/Symfony/Component/Translation/Tests/Formatter/IntlMessageFormatterTest.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616

1717
class IntlMessageFormatterTest extends \PHPUnit\Framework\TestCase
1818
{
19-
public function setUp()
19+
protected function setUp()
2020
{
2121
if (!\extension_loaded('intl')) {
22-
$this->markTestSkipped(
23-
'The Intl extension is not available.'
24-
);
22+
$this->markTestSkipped('The Intl extension is not available.');
2523
}
2624
}
2725

@@ -30,13 +28,13 @@ public function setUp()
3028
*/
3129
public function testFormat($expected, $message, $arguments)
3230
{
33-
$this->assertEquals($expected, trim($this->getMessageFormatter()->format($message, 'en', $arguments)));
31+
$this->assertEquals($expected, trim((new IntlMessageFormatter())->format($message, 'en', $arguments)));
3432
}
3533

3634
public function testInvalidFormat()
3735
{
3836
$this->expectException(InvalidArgumentException::class);
39-
$this->getMessageFormatter()->format('{foo', 'en', array(2));
37+
(new IntlMessageFormatter())->format('{foo', 'en', array(2));
4038
}
4139

4240
public function testFormatWithNamedArguments()
@@ -64,8 +62,7 @@ public function testFormatWithNamedArguments()
6462
other {{host} invites {guest} as one of the # people invited to their party.}}}}
6563
_MSG_;
6664

67-
$formatter = $this->getMessageFormatter();
68-
$message = $formatter->format($chooseMessage, 'en', array(
65+
$message = (new IntlMessageFormatter())->format($chooseMessage, 'en', array(
6966
'gender_of_host' => 'male',
7067
'num_guests' => 10,
7168
'host' => 'Fabien',
@@ -90,9 +87,4 @@ public function provideDataForFormat()
9087
),
9188
);
9289
}
93-
94-
private function getMessageFormatter()
95-
{
96-
return new IntlMessageFormatter();
97-
}
9890
}

0 commit comments

Comments
 (0)
0