Skip to main content
Version: 3.x.x

Ruby on Rails .yaml

Structured YAML format is a generic format enabling you to export translations to YAML files with array support. When exporting in this format, you can choose from various placeholder & message formats listed below.

Read more in Ruby in Rails official internationalization docs.

Example of structured YAML

button: "Save"

When importing such YAML, the nested elements are converted into flat keys. So, the example above will be imported the same way as this one:

"": "Save"

Format specification

Ruby on rails is specific, since it has a language tag in the root. Other that, it has the same features and behaves identically to the generic structured YAML format.

The message format and placeholder conversion

When importing data to Tolgee from the Flat YAML files, you can either enable or disable the conversion to the Tolgee Universal ICU placeholders. The conversion is enabled by default. You can also disable the conversion globally in the project settings. We recommend keeping the conversion enabled, as it brings many benefits. Read more about the benefits of Tolgee Universal ICU placeholders.

When the conversion is disabled, the original placeholders (e.g., `%{name}, %<count>d). are preserved. The message format is automatically detected when importing data in Flat YAML format. When exporting, you can choose from message & placeholder formats listed above.

Placeholder conversion specification

Only specifiers specified in the table below are supported. Tolgee doesn't support additional flags and modifiers and placeholders using them are not converted.

SpecifierICU typeExampleConverted to ICUNote
%N/A%%%%% is the way how to render %, in ICU we don't have such concept, so we just add %. When exporting, the % is converted back to %%.
snone%s, %<name>s{0}, {name}
dnumber%d, %<count>d{0, number}, {count, number}
fnumber, [precision string]%f, %<value>f{0, number, 0.000000}, {value, number, 0.000000}By default %f uses 6 decimal places, that's why we convert it to the number with such precision. %.2 f would be {0, number, 0.00} and so on.
enumber, scientific%e, %<value>e{0, number, scientific}, {value, number, scientific}%E is not supported

Ruby supports named placeholders. Such placeholders are wrapped with curly brackets, e.g., %{name}. When also specifying the specifier, the name is wrapped in angle brackets, e.g., %<name>s. The name is then used to convert to ICU.

Ruby also supportsn$ positional specifiers. They are converted to the zero-based argument index. E.g. I am %2$@, and I have %1$lld dogs. is converted toI am {1} and I have {0, number} dogs.

Importing / Exporting in general

To read more about importing and exporting with Tolgee, continue to import section or export section.