Symfony2 Localization

There are several ways how to localize your Symfony2 application. One resource file format that can be used to externalize your segments is YAML. While YAML is a well defined standard, the parser used in Symfony2 is known for implementing just a subset of this standard. So it is important to use the documentation of Symfony2 over common YAML documentation to get things right.

If you are looking for information on how to handle your Ruby on Rails i18n YAML files please take a look at this guide: Ruby on Rails Localization


  • Symfony2 uses a flat YAML structure. A hierarchical structure cannot be interpreted by the Symfony2 YAML parser.

  • The keys can either be constructed by using the source language text or by using generic keys. Lingohub recommends to use generic keys.

  • Key-value pairs are delimited with a colon (:).

  • Values can be surrounded by single or double quotes.

  • Comments start with a hash sign (#) and are ignored by all known parsers. However, in the Lingohub context, all comment lines are parsed directly preceding a key-value pair (with no blank lines in between) and are treated as translation descriptions or LingoCheck rules belonging to that line.

  • The placeholder syntax is as the following: “%{placeholder}”

  • YAML array syntax is not allowed by the Symfony2 YAML parser.

  • Lingohub cannot guarantee to use the same quoting and escaping as imported, when exporting a file, but will always produce a syntactically correct file.


Additional example files can be accessed here.

# a generic key Please enter an author name.

# placeholder example
users.salutation: "Hello %{username}"

# source language text used as key
"Symfony2 is great": J'aime Symfony2


Last updated