How to Find Errors in Translation Files

Version: 3.3
Edit this page

Warning: You are browsing the documentation for Symfony 3.3, which is no longer maintained.

Read the updated version of this page for Symfony 5.3 (the current stable version).

How to Find Errors in Translation Files

Symfony processes all the application translation files as part of the process that compiles the application code before executing it. If there's an error in any translation file, you'll see an error message explaining the problem.

If you prefer, you can also validate the contents of any YAML and XLIFF translation file using the lint:yaml and lint:xliff commands:

1
2
3
4
5
6
7
8
9
10
11
# lint a single file
$ ./bin/console lint:yaml app/Resources/translations/messages.en.yml
$ ./bin/console lint:xliff app/Resources/translations/messages.en.xlf

# lint a whole directory
$ ./bin/console lint:yaml app/Resources/translations
$ ./bin/console lint:xliff app/Resources/translations

# lint a specific bundle
$ ./bin/console lint:yaml @AppBundle
$ ./bin/console lint:xliff @AppBundle

New in version 3.3

The lint:xliff command was introduced in Symfony 3.3.

The linter results can be exported to JSON using the --format option:

1
2
3
# lint a single file
$ ./bin/console lint:yaml app/Resources/translations --format=json
$ ./bin/console lint:xliff app/Resources/translations --format=json
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.