There are several ways 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 Symfony2's documentation over common YAML documentation to get things right.

If you need information on handling your Ruby on Rails i18n YAML files, please look at this guide: Ruby on Rails Localization.

Format

  • Symfony2 uses a flat YAML structure. The Symfony2 YAML parser cannot interpret a hierarchical structure.
  • The keys can either be constructed using the source language text or using generic keys. Lingohub recommends using 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 segment descriptions.
  • The placeholder syntax is as follows: %{placeholder}
  • YAML array syntax is not allowed by the Symfony2 YAML parser.
  • Lingohub cannot guarantee that it will use the same quoting and escaping as imported when exporting a file, but it will always produce a syntactically correct file.

Examples

Additional example files can be accessed here.

# a generic key
author.name.not_blank: Please enter an author name.

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

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

References