diff --git a/translation/debug.rst b/translation/debug.rst index afe1c778e77..74e52783245 100644 --- a/translation/debug.rst +++ b/translation/debug.rst @@ -180,3 +180,33 @@ unused or only the missing messages, by using the ``--only-unused`` or $ php bin/console debug:translation en --only-unused $ php bin/console debug:translation en --only-missing + +Debug Command Exit Codes +------------------------ + +The exit code of the ``debug:translation`` command changes depending on the +status of the translations. Use the following public constants to check it:: + + use Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand; + + // generic failure (e.g. there are no translations) + TranslationDebugCommand::EXIT_CODE_GENERAL_ERROR; + + // there are missing translations + TranslationDebugCommand::EXIT_CODE_MISSING; + + // there are unused translations + TranslationDebugCommand::EXIT_CODE_UNUSED; + + // some translations are using the fallback translation + TranslationDebugCommand::EXIT_CODE_FALLBACK; + +These constants are defined as "bit masks", so you can combine them as follows:: + + if (TranslationDebugCommand::EXIT_CODE_MISSING | TranslationDebugCommand::EXIT_CODE_UNUSED) { + // ... there are missing and/or unused translations + } + +.. versionadded:: 5.1 + + The exit codes were introduced in Symfony 5.1