Category: translation

symfony entity function autput in twig translate

In my project I have entity with atribute type, for display in twig templates I use function public function getTypeString(): string { $types = self::getPredefinedTypes(); return $types[$this->type]; } public static function getPredefinedTypes(): array { return [ self::PROJECT_TYPE_ONETIME => ‘onetime’, self::PROJECT_TYPE_ONGOING…

Does the symfony translation system support an arbitrary-length list of elements to be concatenated?

I need to translate variable-length sentences in Symfony 3.4. Sample sentence: “Included: 4 breakfasts, 1 brunch and 3 dinners.” For the exemple let’s say the following constraints: I have to express the number of breakfasts, brunches, lunches and dinners that…

How symfony read locale for php-translation

I want to use php-translation/symfony-bundle in my Symfony 4 project. I have followed the configuration step. translation: locales: [“fr”, “en”, “de”, “nl”] configs: applicationName: dirs: [‘%kernel.project_dir%/templates’, ‘%kernel.project_dir%/src’] output_dir: ‘%kernel.project_dir%/translations’ excluded_names: [‘*TestCase.php’, ‘*Test.php’] excluded_dirs: [cache, data, logs] remote_storage: [‘php_translation.adapter.loco’] But I…

Defining a locale for twig template translations when using `translation:update`

I’m having a bit of trouble with Symfony twig translations, and I hope someone here can clarify. Say I have a file /templates/general/hello_world.twig , with the contents: {% trans with { ‘%name%’: name, } %} “Hello %name%” {% endtrans %}…

removed MessageSelector in Symfony/Component/Translation

I just tried to upgrade to Symfony 5.0, however, I get the following error: You have requested a non-existent service “translator.selector”. In my code in services.yaml I have SymfonyComponentTranslationMessageSelector: ‘@translator.selector’ https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Translation/CHANGELOG.md I saw that it was removed. How should I…

Symfony translation ignores curly braces in parameters

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’,…

Translation of flash messages with parameters in Symfony 4

I have a problem with flash messages in Symfony 4 and translation. Translation of simple flash messages is working fine: $this->addFlash(‘success’, ‘flashmessage.project_deleted’); But now I want to add some parameters to the flash messages and I have no idea how…