Tomas S.
Tomas S.

Reputation: 329

Update Symfony translation files with nested keywords

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?

Upvotes: 2

Views: 639

Answers (1)

SubCore
SubCore

Reputation: 591

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.

Upvotes: 1

Related Questions