Formats / Rails YAML

Rails YAML, with the locale root written for you

A Rails locale file looks like plain nested YAML. Two details decide whether the file you get back loads as the language you meant.

.yml / .yaml

The root key is the language, and it has to change on the way out

Rails wraps a whole locale file in one top-level key: en: in the English file, cs: in the Czech one. Copy the English file, translate every value and forget the root, and Rails loads your Czech strings as a second copy of English.

Linguiqo reads the root key as the language rather than as part of every key, so cart.empty in en.yml and cart.empty in cs.yml are recognised as the same string. On export the root is written as the language being exported, spelled the way your file spells it: pt-BR stays pt-BR.

A file whose single top-level key is not a language, such as app: in a Symfony catalogue, keeps that key exactly as it was.

Nested keys become one address per string

Each nested level turns into a dot, so the translator sees checkout.cart.empty, the same name your code passes to t(). On export the dots become nesting again, and a list stays a list: errors: [First, Second] comes back as a list, not as a hash keyed 0 and 1.

Long values are never wrapped across lines, and accented characters are written as themselves rather than as escape sequences, so the file stays readable in a diff.

Interpolations are checked, not just copied

A translation that drops %{count} or renames %{name} to %{nom} renders a literal placeholder or raises at runtime. Linguiqo recognises Rails interpolation as a placeholder, and the quality checks flag a translation whose placeholders do not match the source.

Questions

Can I import .yaml as well as .yml?

Yes. Both extensions are recognised, and the format is detected from the file name when you upload.

How are Rails pluralization keys handled?

A pluralization hash such as items: { one: ..., other: ... } comes in as separate strings, items.one and items.other, and goes back out in the same nesting. Linguiqo does not add the extra forms a language like Czech or Polish needs, so for those languages add the few and many keys to the source file.

Does a key with a context survive?

YAML has no field for context, so each key holds one text. If a project has two strings under one key, the export says which one would be left out before it writes the file.

Upload a Rails YAML file and see

The demo reads a real file of yours and shows what came back. No account, nothing kept.

Open the demo

What Linguiqo is