2

Symfony has support for nested keyword in translation files, for example:

symfony:
    is:
        great: Symfony is great
        amazing: Symfony is amazing
    has:
        bundles: Symfony has bundles

So now I can use this:

{% trans from 'domain' %}symfony.is.great{% endtrans %}

or this:

{% trans from 'domain' %}symfony.is.amazing{% endtrans %}

and everything works properly, as the official documentation says.

But, when I call command for update translation files, everything nested keywords will be converted to this:

symfony.is.great: Symfony is great
symfony.is.amazing: Symfony is amazing
symfony.has.bundles: Symfony has bundles

I need nested keywords to be preserved and properly generated. So if I define in template keyword symfony.is.great and symfony.is.amazing and call command php bin/console translation:update --force en, I need files with nested keywords as I mentioned above in the first example.

Is it possible somehow?

Tomas S.
  • 329
  • 2
  • 9

1 Answers1

1

Yes, its possible with the --as-tree flag.

So you can use php bin/console translation:update --force --format=yaml --as-tree=3 en. The '3' defines the level where to switch back to inline yaml.

SubCore
  • 373
  • 2
  • 7
  • Hmm, the console says: "The --as-tree option does not exist." I didn't find anything about this option. Are you sure it exists? – Tomas S. Dec 15 '21 at 07:33
  • oh my fault. I've overread the Symfony4 Tag. This option was merged to version 5.2 at PR 38393 [link](https://github.com/symfony/symfony/pull/38393) – SubCore Dec 17 '21 at 07:42