From 6ac56d3f93ccd476d18b78f10ff32aa187960cd8 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 16 Sep 2018 15:19:16 -0700 Subject: [PATCH 1/7] Adding IntlMessageConverter --- .../Resources/config/console.xml | 7 ++ .../Command/IntlConvertCommand.php | 96 +++++++++++++++ .../Tests/Util/IntlMessageConverterTest.php | 79 ++++++++++++ .../Translation/Util/IntlMessageConverter.php | 116 ++++++++++++++++++ 4 files changed, 298 insertions(+) create mode 100644 src/Symfony/Component/Translation/Command/IntlConvertCommand.php create mode 100644 src/Symfony/Component/Translation/Tests/Util/IntlMessageConverterTest.php create mode 100644 src/Symfony/Component/Translation/Util/IntlMessageConverter.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml index 9553d4d60d7ce..e346a7f66e193 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml @@ -113,6 +113,13 @@ + + + + + + + diff --git a/src/Symfony/Component/Translation/Command/IntlConvertCommand.php b/src/Symfony/Component/Translation/Command/IntlConvertCommand.php new file mode 100644 index 0000000000000..fdd08256d1f8d --- /dev/null +++ b/src/Symfony/Component/Translation/Command/IntlConvertCommand.php @@ -0,0 +1,96 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Translation\Command; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\HttpKernel\KernelInterface; +use Symfony\Component\Translation\MessageCatalogue; +use Symfony\Component\Translation\Reader\TranslationReaderInterface; +use Symfony\Component\Translation\Util\IntlMessageConverter; +use Symfony\Component\Translation\Writer\TranslationWriterInterface; + +/** + * Convert to Intl styled message format. + * + * @author Tobias Nyholm + */ +class IntlConvertCommand extends Command +{ + protected static $defaultName = 'translation:convert-to-icu-messages'; + + private $writer; + private $reader; + + public function __construct(TranslationWriterInterface $writer, TranslationReaderInterface $reader) + { + parent::__construct(); + + $this->writer = $writer; + $this->reader = $reader; + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setDescription('Convert from Symfony 3 plural format to ICU message format.') + ->addArgument('locale', InputArgument::REQUIRED, 'The locale') + ->addArgument('path', null, 'A file or a directory') + ->addOption('domain', null, InputOption::VALUE_OPTIONAL, 'The messages domain') + ->addOption('output-format', null, InputOption::VALUE_OPTIONAL, 'Override the default output format', 'xlf') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new SymfonyStyle($input, $output); + $path = $input->getArgument('path'); + $locale = $input->getArgument('locale'); + $domain = $input->getOption('domain'); + /** @var KernelInterface $kernel */ + $kernel = $this->getApplication()->getKernel(); + + // Define Root Paths + $transPaths = $kernel->getProjectDir().'/translations'; + if (null !== $path) { + $transPaths = $path; + } + + // load any existing messages from the translation files + $currentCatalogue = new MessageCatalogue($locale); + if (!is_dir($transPaths)) { + throw new \LogicException('The "path" must be a directory.'); + } + $this->reader->read($transPaths, $currentCatalogue); + + $allMessages = $currentCatalogue->all($domain); + if (null !== $domain) { + $allMessages = array($domain => $allMessages); + } + + $updated = array(); + foreach ($allMessages as $messageDomain => $messages) { + foreach ($messages as $key => $message) { + $updated[$messageDomain][$key] = IntlMessageConverter::convert($message); + } + } + + $this->writer->write(new MessageCatalogue($locale, $updated), $input->getOption('output-format'), array('path' => $transPaths)); + } +} diff --git a/src/Symfony/Component/Translation/Tests/Util/IntlMessageConverterTest.php b/src/Symfony/Component/Translation/Tests/Util/IntlMessageConverterTest.php new file mode 100644 index 0000000000000..ebe68f53fe0e2 --- /dev/null +++ b/src/Symfony/Component/Translation/Tests/Util/IntlMessageConverterTest.php @@ -0,0 +1,79 @@ +assertEquals($output, $result); + } + + /** + * We cannot use negative Inf together with positive Inf. + */ + public function testImpossibleConvert() + { + $this->expectException(\LogicException::class); + IntlMessageConverter::convert(']-Inf, -2[ Negative|]1,Inf[ Positive'); + } + + public function getTestData() + { + yield array( + '{0} There are no apples|{1} There is one apple|]1,Inf[ There %name% are %count% apples', + << + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Translation\Util; + +/** + * Convert from Symfony 3's plural syntax to Intl message format. + * {@link https://messageformat.github.io/messageformat/page-guide}. + * + * @author Tobias Nyholm + */ +class IntlMessageConverter +{ + public static function convert(string $message): string + { + $array = self::getMessageArray($message); + + if (1 === \count($array) && isset($array[0])) { + return preg_replace('|%(.*?)%|s', '{$1}', $message); + } + + $icu = self::buildIcuString($array); + + return $icu; + } + + /** + * Get an ICU like array. + */ + private static function getMessageArray(string $message): array + { + $parts = array(); + if (preg_match('/^\|++$/', $message)) { + $parts = explode('|', $message); + } elseif (preg_match_all('/(?:\|\||[^\|])++/', $message, $matches)) { + $parts = $matches[0]; + } + + $intervalRegexp = <<<'EOF' +/^(?P + ({\s* + (\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*) + \s*}) + + | + + (?P[\[\]]) + \s* + (?P-Inf|\-?\d+(\.\d+)?) + \s*,\s* + (?P\+?Inf|\-?\d+(\.\d+)?) + \s* + (?P[\[\]]) +)\s*(?P.*?)$/xs +EOF; + + $standardRules = array(); + foreach ($parts as $part) { + $part = trim(str_replace('||', '|', $part)); + + // try to match an explicit rule, then fallback to the standard ones + if (preg_match($intervalRegexp, $part, $matches)) { + if ($matches[2]) { + foreach (explode(',', $matches[3]) as $n) { + $standardRules['='.$n] = $matches['message']; + } + } else { + $leftNumber = '-Inf' === $matches['left'] ? -INF : (float) $matches['left']; + $rightNumber = \is_numeric($matches['right']) ? (float) $matches['right'] : INF; + + $leftNumber = ('[' === $matches['left_delimiter'] ? $leftNumber : 1 + $leftNumber); + $rightNumber = (']' === $matches['right_delimiter'] ? 1 + $rightNumber : $rightNumber); + + if ($leftNumber !== -INF && INF !== $rightNumber) { + for ($i = $leftNumber; $i < $rightNumber; ++$i) { + $standardRules['='.$i] = $matches['message']; + } + } else { + // $rightNumber is INF or $leftNumber is -INF + if (isset($standardRules['other'])) { + throw new \LogicException(sprintf('%s does not support converting messages with both "-Inf" and "Inf". Message: "%s"', __CLASS__, $message)); + } + $standardRules['other'] = $matches['message']; + } + } + } elseif (preg_match('/^\w+\:\s*(.*?)$/', $part, $matches)) { + $standardRules[] = $matches[1]; + } else { + $standardRules[] = $part; + } + } + + return $standardRules; + } + + private static function buildIcuString(array $data): string + { + $icu = "{ COUNT, plural,\n"; + foreach ($data as $key => $message) { + $message = strtr($message, array('%count%' => '#')); + $message = preg_replace('|%(.*?)%|s', '{$1}', $message); + $icu .= sprintf(" %s {%s}\n", $key, $message); + } + $icu .= '}'; + + return $icu; + } +} From 83bfcb6cea46813a4bf7bbc18d9b019abdcb1ff3 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sat, 22 Sep 2018 11:25:50 +0200 Subject: [PATCH 2/7] minor fix --- .../Component/Translation/Command/IntlConvertCommand.php | 2 +- src/Symfony/Component/Translation/Util/IntlMessageConverter.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Translation/Command/IntlConvertCommand.php b/src/Symfony/Component/Translation/Command/IntlConvertCommand.php index fdd08256d1f8d..97ecfe0f2a731 100644 --- a/src/Symfony/Component/Translation/Command/IntlConvertCommand.php +++ b/src/Symfony/Component/Translation/Command/IntlConvertCommand.php @@ -67,7 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $kernel = $this->getApplication()->getKernel(); // Define Root Paths - $transPaths = $kernel->getProjectDir().'/translations'; + $transPaths = $kernel->getProjectDir().DIRECTORY_SEPARATOR.'translations'; if (null !== $path) { $transPaths = $path; } diff --git a/src/Symfony/Component/Translation/Util/IntlMessageConverter.php b/src/Symfony/Component/Translation/Util/IntlMessageConverter.php index 9b08769a9acd4..5d432b8ade091 100644 --- a/src/Symfony/Component/Translation/Util/IntlMessageConverter.php +++ b/src/Symfony/Component/Translation/Util/IntlMessageConverter.php @@ -42,6 +42,8 @@ private static function getMessageArray(string $message): array $parts = explode('|', $message); } elseif (preg_match_all('/(?:\|\||[^\|])++/', $message, $matches)) { $parts = $matches[0]; + } else { + $parts = array($message); } $intervalRegexp = <<<'EOF' From e83e32e38e7116b1d4cdb27a99f0a7d075d3e2c3 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sat, 22 Sep 2018 11:40:05 +0200 Subject: [PATCH 3/7] Make sure "$parts" are never empty --- .../Translation/Tests/Util/IntlMessageConverterTest.php | 1 + .../Component/Translation/Util/IntlMessageConverter.php | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Translation/Tests/Util/IntlMessageConverterTest.php b/src/Symfony/Component/Translation/Tests/Util/IntlMessageConverterTest.php index ebe68f53fe0e2..6909bf8244a18 100644 --- a/src/Symfony/Component/Translation/Tests/Util/IntlMessageConverterTest.php +++ b/src/Symfony/Component/Translation/Tests/Util/IntlMessageConverterTest.php @@ -29,6 +29,7 @@ public function testImpossibleConvert() public function getTestData() { + yield array('|', '|'); yield array( '{0} There are no apples|{1} There is one apple|]1,Inf[ There %name% are %count% apples', << Date: Sat, 22 Sep 2018 12:06:13 +0200 Subject: [PATCH 4/7] It is called Icu message format. Not Intl --- .../Bundle/FrameworkBundle/Resources/config/console.xml | 2 +- .../{IntlConvertCommand.php => IcuConvertCommand.php} | 6 +++--- ...ssageConverterTest.php => IcuMessageConverterTest.php} | 8 ++++---- .../{IntlMessageConverter.php => IcuMessageConverter.php} | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) rename src/Symfony/Component/Translation/Command/{IntlConvertCommand.php => IcuConvertCommand.php} (94%) rename src/Symfony/Component/Translation/Tests/Util/{IntlMessageConverterTest.php => IcuMessageConverterTest.php} (85%) rename src/Symfony/Component/Translation/Util/{IntlMessageConverter.php => IcuMessageConverter.php} (99%) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml index e346a7f66e193..1debc4f64e788 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml @@ -113,7 +113,7 @@ - + diff --git a/src/Symfony/Component/Translation/Command/IntlConvertCommand.php b/src/Symfony/Component/Translation/Command/IcuConvertCommand.php similarity index 94% rename from src/Symfony/Component/Translation/Command/IntlConvertCommand.php rename to src/Symfony/Component/Translation/Command/IcuConvertCommand.php index 97ecfe0f2a731..f920a391dbf94 100644 --- a/src/Symfony/Component/Translation/Command/IntlConvertCommand.php +++ b/src/Symfony/Component/Translation/Command/IcuConvertCommand.php @@ -20,7 +20,7 @@ use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\Reader\TranslationReaderInterface; -use Symfony\Component\Translation\Util\IntlMessageConverter; +use Symfony\Component\Translation\Util\IcuMessageConverter; use Symfony\Component\Translation\Writer\TranslationWriterInterface; /** @@ -28,7 +28,7 @@ * * @author Tobias Nyholm */ -class IntlConvertCommand extends Command +class IcuConvertCommand extends Command { protected static $defaultName = 'translation:convert-to-icu-messages'; @@ -87,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $updated = array(); foreach ($allMessages as $messageDomain => $messages) { foreach ($messages as $key => $message) { - $updated[$messageDomain][$key] = IntlMessageConverter::convert($message); + $updated[$messageDomain][$key] = IcuMessageConverter::convert($message); } } diff --git a/src/Symfony/Component/Translation/Tests/Util/IntlMessageConverterTest.php b/src/Symfony/Component/Translation/Tests/Util/IcuMessageConverterTest.php similarity index 85% rename from src/Symfony/Component/Translation/Tests/Util/IntlMessageConverterTest.php rename to src/Symfony/Component/Translation/Tests/Util/IcuMessageConverterTest.php index 6909bf8244a18..dcb9b898ebc38 100644 --- a/src/Symfony/Component/Translation/Tests/Util/IntlMessageConverterTest.php +++ b/src/Symfony/Component/Translation/Tests/Util/IcuMessageConverterTest.php @@ -5,16 +5,16 @@ namespace Symfony\Component\Translation\Tests\Util; use PHPUnit\Framework\TestCase; -use Symfony\Component\Translation\Util\IntlMessageConverter; +use Symfony\Component\Translation\Util\IcuMessageConverter; -class IntlMessageConverterTest extends TestCase +class IcuMessageConverterTest extends TestCase { /** * @dataProvider getTestData */ public function testConvert($input, $output) { - $result = IntlMessageConverter::convert($input); + $result = IcuMessageConverter::convert($input); $this->assertEquals($output, $result); } @@ -24,7 +24,7 @@ public function testConvert($input, $output) public function testImpossibleConvert() { $this->expectException(\LogicException::class); - IntlMessageConverter::convert(']-Inf, -2[ Negative|]1,Inf[ Positive'); + IcuMessageConverter::convert(']-Inf, -2[ Negative|]1,Inf[ Positive'); } public function getTestData() diff --git a/src/Symfony/Component/Translation/Util/IntlMessageConverter.php b/src/Symfony/Component/Translation/Util/IcuMessageConverter.php similarity index 99% rename from src/Symfony/Component/Translation/Util/IntlMessageConverter.php rename to src/Symfony/Component/Translation/Util/IcuMessageConverter.php index c27c607a632a7..30eead2619f13 100644 --- a/src/Symfony/Component/Translation/Util/IntlMessageConverter.php +++ b/src/Symfony/Component/Translation/Util/IcuMessageConverter.php @@ -17,7 +17,7 @@ * * @author Tobias Nyholm */ -class IntlMessageConverter +class IcuMessageConverter { public static function convert(string $message): string { From df696075219d4d1284a18119d5deb172c2e25636 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sat, 22 Sep 2018 12:15:45 +0200 Subject: [PATCH 5/7] Allow to specify delimiter --- .../Tests/Util/IcuMessageConverterTest.php | 18 ++++++++++++++++++ .../Translation/Util/IcuMessageConverter.php | 18 +++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Translation/Tests/Util/IcuMessageConverterTest.php b/src/Symfony/Component/Translation/Tests/Util/IcuMessageConverterTest.php index dcb9b898ebc38..cb41f5f190405 100644 --- a/src/Symfony/Component/Translation/Tests/Util/IcuMessageConverterTest.php +++ b/src/Symfony/Component/Translation/Tests/Util/IcuMessageConverterTest.php @@ -18,6 +18,24 @@ public function testConvert($input, $output) $this->assertEquals($output, $result); } + + + public function testConvertWithCustomDelimiter() + { + $result = IcuMessageConverter::convert('Foo #var# bar', '#'); + $this->assertEquals('Foo {var} bar', $result); + + $result = IcuMessageConverter::convert('{0} Foo #var# bar | {1} Bar #var# foo', '#'); + $this->assertEquals( + << $message) { $message = strtr($message, array('%count%' => '#')); - $message = preg_replace('|%(.*?)%|s', '{$1}', $message); + $message = self::replaceVariables($message, $variableDelimiter); $icu .= sprintf(" %s {%s}\n", $key, $message); } $icu .= '}'; return $icu; } + + + private static function replaceVariables(string $message, string $variableDelimiter): string + { + $regex = sprintf('|%s(.*?)%s|s', $variableDelimiter, $variableDelimiter); + + return preg_replace($regex, '{$1}', $message); + } } From 9071df75a751d831538f11c7888c4e637bc0ce2d Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sat, 22 Sep 2018 12:16:20 +0200 Subject: [PATCH 6/7] cs --- .../Component/Translation/Command/IcuConvertCommand.php | 2 +- .../Translation/Tests/Util/IcuMessageConverterTest.php | 2 -- src/Symfony/Component/Translation/Util/IcuMessageConverter.php | 3 +-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Translation/Command/IcuConvertCommand.php b/src/Symfony/Component/Translation/Command/IcuConvertCommand.php index f920a391dbf94..225076a065777 100644 --- a/src/Symfony/Component/Translation/Command/IcuConvertCommand.php +++ b/src/Symfony/Component/Translation/Command/IcuConvertCommand.php @@ -67,7 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $kernel = $this->getApplication()->getKernel(); // Define Root Paths - $transPaths = $kernel->getProjectDir().DIRECTORY_SEPARATOR.'translations'; + $transPaths = $kernel->getProjectDir().\DIRECTORY_SEPARATOR.'translations'; if (null !== $path) { $transPaths = $path; } diff --git a/src/Symfony/Component/Translation/Tests/Util/IcuMessageConverterTest.php b/src/Symfony/Component/Translation/Tests/Util/IcuMessageConverterTest.php index cb41f5f190405..d4b7a00f804e3 100644 --- a/src/Symfony/Component/Translation/Tests/Util/IcuMessageConverterTest.php +++ b/src/Symfony/Component/Translation/Tests/Util/IcuMessageConverterTest.php @@ -18,8 +18,6 @@ public function testConvert($input, $output) $this->assertEquals($output, $result); } - - public function testConvertWithCustomDelimiter() { $result = IcuMessageConverter::convert('Foo #var# bar', '#'); diff --git a/src/Symfony/Component/Translation/Util/IcuMessageConverter.php b/src/Symfony/Component/Translation/Util/IcuMessageConverter.php index ae30ea6f0cabb..c7bb9f9008d93 100644 --- a/src/Symfony/Component/Translation/Util/IcuMessageConverter.php +++ b/src/Symfony/Component/Translation/Util/IcuMessageConverter.php @@ -42,7 +42,7 @@ private static function getMessageArray(string $message): array { if (preg_match('/^\|++$/', $message)) { // If the message only contains pipes ("|||") - return []; + return array(); } elseif (preg_match_all('/(?:\|\||[^\|])++/', $message, $matches)) { $parts = $matches[0]; } else { @@ -119,7 +119,6 @@ private static function buildIcuString(array $data, string $variableDelimiter): return $icu; } - private static function replaceVariables(string $message, string $variableDelimiter): string { $regex = sprintf('|%s(.*?)%s|s', $variableDelimiter, $variableDelimiter); From 6687d9acac8708421f16c12b8f1bf000b8ef2789 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sat, 22 Sep 2018 12:48:09 +0200 Subject: [PATCH 7/7] Renamed to Intl --- .../FrameworkBundle/Resources/config/console.xml | 4 ++-- ...{IcuConvertCommand.php => IntlConvertCommand.php} | 8 ++++---- ...onverterTest.php => IntlMessageConverterTest.php} | 12 ++++++------ ...MessageConverter.php => IntlMessageConverter.php} | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) rename src/Symfony/Component/Translation/Command/{IcuConvertCommand.php => IntlConvertCommand.php} (92%) rename src/Symfony/Component/Translation/Tests/Util/{IcuMessageConverterTest.php => IntlMessageConverterTest.php} (80%) rename src/Symfony/Component/Translation/Util/{IcuMessageConverter.php => IntlMessageConverter.php} (99%) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml index 1debc4f64e788..4369a5549f367 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml @@ -113,10 +113,10 @@ - + - + diff --git a/src/Symfony/Component/Translation/Command/IcuConvertCommand.php b/src/Symfony/Component/Translation/Command/IntlConvertCommand.php similarity index 92% rename from src/Symfony/Component/Translation/Command/IcuConvertCommand.php rename to src/Symfony/Component/Translation/Command/IntlConvertCommand.php index 225076a065777..745881c634273 100644 --- a/src/Symfony/Component/Translation/Command/IcuConvertCommand.php +++ b/src/Symfony/Component/Translation/Command/IntlConvertCommand.php @@ -20,7 +20,7 @@ use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\Reader\TranslationReaderInterface; -use Symfony\Component\Translation\Util\IcuMessageConverter; +use Symfony\Component\Translation\Util\IntlMessageConverter; use Symfony\Component\Translation\Writer\TranslationWriterInterface; /** @@ -28,9 +28,9 @@ * * @author Tobias Nyholm */ -class IcuConvertCommand extends Command +class IntlConvertCommand extends Command { - protected static $defaultName = 'translation:convert-to-icu-messages'; + protected static $defaultName = 'translation:convert-to-intl-messages'; private $writer; private $reader; @@ -87,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $updated = array(); foreach ($allMessages as $messageDomain => $messages) { foreach ($messages as $key => $message) { - $updated[$messageDomain][$key] = IcuMessageConverter::convert($message); + $updated[$messageDomain][$key] = IntlMessageConverter::convert($message); } } diff --git a/src/Symfony/Component/Translation/Tests/Util/IcuMessageConverterTest.php b/src/Symfony/Component/Translation/Tests/Util/IntlMessageConverterTest.php similarity index 80% rename from src/Symfony/Component/Translation/Tests/Util/IcuMessageConverterTest.php rename to src/Symfony/Component/Translation/Tests/Util/IntlMessageConverterTest.php index d4b7a00f804e3..7aef95df822b8 100644 --- a/src/Symfony/Component/Translation/Tests/Util/IcuMessageConverterTest.php +++ b/src/Symfony/Component/Translation/Tests/Util/IntlMessageConverterTest.php @@ -5,25 +5,25 @@ namespace Symfony\Component\Translation\Tests\Util; use PHPUnit\Framework\TestCase; -use Symfony\Component\Translation\Util\IcuMessageConverter; +use Symfony\Component\Translation\Util\IntlMessageConverter; -class IcuMessageConverterTest extends TestCase +class IntlMessageConverterTest extends TestCase { /** * @dataProvider getTestData */ public function testConvert($input, $output) { - $result = IcuMessageConverter::convert($input); + $result = IntlMessageConverter::convert($input); $this->assertEquals($output, $result); } public function testConvertWithCustomDelimiter() { - $result = IcuMessageConverter::convert('Foo #var# bar', '#'); + $result = IntlMessageConverter::convert('Foo #var# bar', '#'); $this->assertEquals('Foo {var} bar', $result); - $result = IcuMessageConverter::convert('{0} Foo #var# bar | {1} Bar #var# foo', '#'); + $result = IntlMessageConverter::convert('{0} Foo #var# bar | {1} Bar #var# foo', '#'); $this->assertEquals( <<expectException(\LogicException::class); - IcuMessageConverter::convert(']-Inf, -2[ Negative|]1,Inf[ Positive'); + IntlMessageConverter::convert(']-Inf, -2[ Negative|]1,Inf[ Positive'); } public function getTestData() diff --git a/src/Symfony/Component/Translation/Util/IcuMessageConverter.php b/src/Symfony/Component/Translation/Util/IntlMessageConverter.php similarity index 99% rename from src/Symfony/Component/Translation/Util/IcuMessageConverter.php rename to src/Symfony/Component/Translation/Util/IntlMessageConverter.php index c7bb9f9008d93..0867a963fd11b 100644 --- a/src/Symfony/Component/Translation/Util/IcuMessageConverter.php +++ b/src/Symfony/Component/Translation/Util/IntlMessageConverter.php @@ -17,7 +17,7 @@ * * @author Tobias Nyholm */ -class IcuMessageConverter +class IntlMessageConverter { public static function convert(string $message, string $variableDelimiter = '%'): string {