Main menu

JSON language pack formats supported by the importer

JSON is a generic file format that can have any structure. This makes importing difficult, so Loco recognizes the following structures as translation mappings:

Flat

A flat structure will be imported as simple key/value pairs, for example:

{ 
    "hello" : "Hello World", 
    "goodbye" : "So long!" 
}

This will import two assets with IDs "hello" and "goodbye", with language texts "Hello World" and "So long!".

Nested

Loco supports key folding for generic nested structures. For example:

{
    "pleasantry": { 
        "hello" : "Hello World", 
        "goodbye" : "So long!" 
    }
}

This will import two assets with dot-separated IDs "pleasantry.hello" and "pleasantry.goodbye".

Plurals

Loco supports plural definitions as either JSON Arrays, or JSON objects with keys zero, one, two, few, many, other:

{
    "foo" : [ "1 foo", "%u foos" ],
    "bar" : { "one" : "1 bar", "other" : "%u bars" }
}

This will import two singular assets with IDs "foo" and "bar" linked to their respective plural forms "foo-plural" and "bar-plural". Read more about how Loco handles plurals.

Language mapping

The examples above show JSON files containing a single language mapped by a generic key. You may instead require bilingual mapping, similar to this:

{
    "Hello World" : "Bonjour",
    "So long!" : "Adieu!"
}

Bilingual mapping can be achieved by telling Loco that the keys are your source language and the values are your target language. In this case Loco will import two languages and automatically generate asset IDs "hello-world" and "so-long".

Chrome extensions

Loco supports the format used in messages.json files for Chrome extensions.

See Chrome extension docs