YAML (YAML Ain't Markup Language) is a human-readable data serialization standard commonly used for configuration files and data exchange between languages with different data structures. YAML files are often used in localization for managing and organizing translation strings due to their readability and simplicity. Lokalise supports YAML files version 1.2, enabling efficient translation management within your projects.
Technical information
Overview
Format name:
YAML
File extensions:
.yaml, .yml
Common use cases:
Managing and organizing configuration settings and localization strings in various applications.
Technical details:
Structure: YAML files consist of key-value pairs that can be nested to represent hierarchical data. Indentation is used to denote structure, and keys and values are separated by a colon (
:
).Encoding: UTF-8
File structure
Here's an example of a typical YAML file used for localization:
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.
Integer keys
If you are using integers as keys, they must be quoted to avoid unexpected results. This is enforced by some frameworks, even though it is not strictly required by the YAML format.
en:
app:
title: "Lokalise"
:yes: "Yes"
:no: "No"
"078": "Value"
"001": "Integer Key"
bacon:
one: "1 bacon"
other: "count bacons"
Arrays
When storing arrays in your YAML files, follow these rules:
Use square brackets
[ ]
for single-line arrays (flow sequence), which can be split into 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
Using with Lokalise
Lokalise supports YAML files, allowing you to manage and translate your localization strings efficiently.
Supported project types
Please note that YAML files can be uploaded only to Web and mobile projects.
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"