Andrei Herford Andrei Herford - 10 months ago 72
Twig Question

Find missing "empty" translation in Symfony project

While checking the logs of my Symfony 2.8 project I came across the following warnings:

Translation not found.
Context: { "id": "", "domain": "messages", "locale": "de" }
Context: { "id": "form_cancel", "domain": "forms", "locale": "de" }

Finding and fixing the code that used the missing
translation was no problem. But how can I find the code that uses the empty

I already tried to use
to find code like
, etc. within my templates, without any result.

I think the most likely source of the problem is something like
{{ someVar|trans }}
within a template, where
is empty / not set. I already search for such code, but also with no result.

Isn't there any option/possibility to get more detailed information about the source the missing translation? Other warning are created with information about the source file and even the line of code. Is it possible to get this information for missing translations as well?

Answer Source

As explained in the documentation, you can use the console to find the missing translations:

php bin/console debug:translation de AcmeDemoBundle --only-missing

You can also specify the domain you want to search in:

php bin/console debug:translation de AcmeDemoBundle --only-missing --domain=messages