-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Closed
Description
Symfony version(s) affected: 5.1.0
Description
Messages written in the ICU format are not being translated properly. By this I mean that the ICU format string itself is returned. I assume I'm doing something wrong, since I ran the tests in symfony/translation
and they all pass, and I saw that some tested for what I'm trying to do.
I used the example from the documentation. I tried it in tests and in a controller.
How to reproduce
tests:
static::bootKernel();
$translator = static::$container->get(TranslatorInterface::class);
static::assertSame('2 apples', $translator->trans('{{count}, plural, =1 {1 apple} other {{count} apples}}', ['{count}' => 2]));
controller:
echo $translator->trans('{{count}, plural, =1 {1 apple} other {{count} apples}}', ['{count}' => 0]);
echo $translator->trans('{{count}, plural, =1 {1 apple} other {{count} apples}}', ['{count}' => 0], 'foo+intl-icu');
echo $translator->trans('num_of_apples', ['apples' => 1], 'foo+intl-icu');
and foo+intl-icu.en.yaml
has (from this doc page)
num_of_apples: >-
{apples, plural,
=0 {There are no apples}
one {There is one apple...}
other {There are # apples!}
}
(different on purpose to make sure the file was being loaded)
Additional context
The outputs from the controller are:
{0, plural, =1 {1 apple} other {0 apples}}
{0, plural, =1 {1 apple} other {0 apples}}
{1, plural, =0 {There are no 1} one {There is one apple...} other {There are # 1!} }
I also tested on a new project.