Main menu

Yaml language pack formats supported by the importer

Yaml is a generic file format that can have any structure. This makes importing difficult, so Loco recognizes the following structures as translation mappings:

Flat

A flat structure will be imported as simple key/value pairs, for example:

hello: Hello World

This will import a single asset with ID hello and source text "Hello World"

Symfony

Symfony supports key folding for nested structures, and so does Loco. For example:

pleasantry:
  hello: "Hello World"
  goodbye: "So long!"

This will import two assets with dot-separated IDs pleasantry.hello and pleasantry.goodbye.

See also Symfony translation component

Rails

Ruby on Rails translations can be imported, but as they have a locale key they make for a special case:

fr:
  hello: "Bonjour tout le monde"
  goodbye: "Au revior"

This will import a single asset with ID hello and French translation "Bonjour tout le monde". The same key folding rules as above are applied, but the "fr" key is ignored.

Note that to avoid potential conflicts with the Symfony format, the Rails format will only be identified if the Yaml document has a single top-level key that looks like a country code. Multiple locales per file are not supported for Yaml imports.

See also guides.rubyonrails.org/i18n.html

Lookup keys

Your Yaml file may by mapped by Asset IDs or by full texts, so when importing you must tell Loco what to do. For example:

Hello World: "Bonjour tout le monde"

This will import an English translation and a French translation, but only if you tell Loco that the keys are English and the values are French. See General notes on importing for how to specify the locales.