YAML
Nick Ustinov avatar
Written by Nick Ustinov
Updated over a week ago

Lokalise supports YAML files version 1.2.

en:
  app:
    title: "Lokalise"
    :yes: "Yes"
    :no: "No"
    bacon:
      one: "1 bacon"
      other: "{{count}} bacons"

When adding a new key via the web interface, use : to refer to YAML levels, for example app:title. You can override the default separator (:) with a dot (.) in project settings > Advanced options.

Please note that if you are using integers as keys, they have to be quoted, otherwise you might get unexpected results. While this is not strictly required by the YAML format, it's enforced by some frameworks. Take a look at the following example:

en:
app:
title: "Lokalise"
:yes: "Yes"
:no: "No"
"078": "Value"
"001": "Integer Key"
bacon:
one: "1 bacon"
other: "count bacons"

You can see that all integer keys are quoted which is correct.

Arrays

Please follow these rules when storing arrays in your YAML files:

  • Use square brackets [ ] for single line arrays (flow sequence) which can be split to multiline

  • Use dashes - for multiline arrays (block sequence)

Here's an example of a multiline notation:

key: ["value1",
"value2",
"value3",
"value4",
"value5"]

You can also convert it to a block sequence:

key:
- value1
- value2
- value3
- value4
- value5

Known issues and limitations

Language codes

When using language codes as the root key in your YAML file, ensure that the code is supported by Lokalise. You can verify this by either:

  • Using the List system languages API endpoint.

  • Clicking the New language button in the project editor and searching for the language code.

Then just search for the language code:

As you can see, Lokalise supports pr_BR language code, so your YAML file might look like this:

pt_BR:
key1: "Lokalise"

However, if you use an unsupported format like ptbr, Lokalise will not recognize it as a language code. Instead, it will create a key named ptbr.key1:

ptbr:
key1: "Lokalise"
Did this answer your question?