If you are referring to translations inside your code and not inside the templates you will have to write a custom function:
private function translate($translationKey, array $parameters = array(), $translationDomain = 'messages')
{
$tranlation = $this->get('translator.default')->trans($translationKey, $parameters, $translationDomain);
if ($tranlation != $translationKey) {
return $tranlation;
}
else {
throw new \Exception();
}
}
Hint: You can/should create a custom exception for this case
Update:
What you want will only be possible if you create your own translator... this translator class should return null
if the translation could not be found:
https://github.com/Orbitale/TranslationBundle/blob/master/Translation/Translator.php
Additional Info (referring to the comment):
The info field for missing translations in the symfony developer toolbar seems to be quite new, introduced in a late 2.6 or an early 2.7 release...
anyway it would look like this:
But: I just noticed that you can see missing translation-warnings also in earlier versions, you will find them in the toolbar profiler in Logs
section