When using the symfony translation module to translate a piece of code it seems that symfony is ignoring the curly braces.
<trans-unit id="test">
<source>test<source>
<target>
test {test}
</target>
</trans-unit>
When using the following Translator
config.
$translator = new Translator("en");
$translator->addLoader('xlf', new XliffFileLoader());
$translator->addResource('xlf', 'translations/messages+intl-icu.en.xlf', 'en');
$translator->setFallbackLocales(["en"]);
$message = $translator->trans("test", ["test" => "error"], null, "en");
Produces the following translation: error {error}
while I would expect test error
Is this an error in my config somewhere or did I misunderstand how the replacement should take place?
My symfony versions are as follows.
"symfony/translation": "v5.0.2",
"symfony/config": "v5.0.2"
According to the documentation (https://symfony.com/doc/current/translation/message_format.html)
Everything within the curly braces ({...}) is processed by the formatter and replaced by its placeholder:
Is this an error in Symfony or am I using it wrong?
I encountered the same issue and asked : https://github.com/symfony/symfony/issues/36461
Answer : you need to pass ['{test}' => 'error']
as the parameters array, including the curly braces in the key string.