• Documentation
  • File formats
  • YAML (Ruby, etc.)

YAML (Ruby, etc.)

  • File extensions: .yaml, .yml
  • i18n type: YML

YAML is used as an i18n format by some projects, such as those built on top of Ruby on Rails.

YAML supports various datatypes (from simple to user defined datatypes). Of those, it makes sense to translate only string-like values. So, Transifex ignores int, float, symbols, variables and other non string and non-container (i.e. lists and mappings) datatypes during importing YAML files.

Regarding container datatypes, Transifex imports lists as a single segment, whereas for mappings Transifex will create a segment per element. Block literals in YAML are also supported.

When a YAML file is downloaded from Transifex for use, it only contains entries that have been translated in the specific language. Additionally, if the requested language is the source language of the resource, the original comments of the source file will also be included in the downloaded file. If the user asked for reviewed translations only, then only entries with reviewed translations will be included instead. However, files that are downloaded for offline translation include all entries, regardless of whether they have been translated or not. Comments from the original source file are also included.

It is recommended that the indentation used in a YAML file is uniform throughout the file.

Additionally, Transifex's YAML handler expects the source YAML file to have a single root element, which is the language code for the YAML file. The language code can have one of the forms xx, xx-XX and xx_XX (for instance, en, en_US or en-US).

Transifex also supports developer comments in YAML files. A valid YAML comment preceding any of the elements will be saved as comment for the source string extracted from the element. For instance, in the following case the comment will be associated with the entry:

        # This is a comment for Libraries.
        libraries: 'Libraries'

And there's also support for multiple-line comments

        # This is a comment for Libraries with
        # two lines.
        libraries: 'Libraries'

Plurals Support

Transifex YML parser can successfully identify pluralized entries in a YML file file. For more details about how pluralized strings are handled by Transifex, please refer to our documentation guide here.

Below, there are some illustrative examples based on the language plural rules that CLDR standards provide:

English language file

    one:   "less than a minute"
    other: "less than %{count} minutes"
    one: "1 error"
    other: "%{count} errors"

Arabic language file

    zero: "أقل من %{count} دقيقة"
    one: "أقل من دقيقة"
    two: "أقل من %{count} دقيقة"
    few: "أقل من %{count} دقيقة"
    many: "أقل من %{count} دقيقة"
    other: "أقل من %{count} دقيقة"
    zero: "أخطاء %{count}"
    one: "خطأ واحد"
    two: "أخطاء %{count}"
    few: "أخطاء %{count}"
    many: "أخطاء %{count}"
    other: "أخطاء %{count}"