Main menu

Import assets and translations from a language pack file

POST https://localise.biz/api/import/{ext} 

The import API loads translations from various language pack formats into the currently authenticated project.

Take note of how the index and locale parameters are used to describe how your file will be imported. By leaving these fields empty Loco will try to guess your intentions, but it's advisable to specify all parameters if in any doubt. See examples.

It's recommended that you set async=1 for large files. This will cause the import to run in the background. When running asynchronously you will receive a 201 code (instead of 200) and the Location header will contain a URI for checking progress.

When running synchronously the response object will include the state of each locale affected by the import.

See Import settings for full details on all these options.

URI parameters

ext

File extension for the type of file data you're importing

arb | bplist | csv | ini | json | mo | php | plist | po | pot | properties | res | resx | strings | tmx | ts | txt | xlf | xml | yml required
index

Specify whether translations in your file are indexed by generic IDs or human-readable source text

id | text optional
locale

Specify target locale if importing translations

string optional
format

Hint for generic file types (like JSON) that don't declare their schema. Reciprocal to the export parameter of the same name

string optional
async

Specify that import should be done asynchronously (recommended for large files)

boolean optional
path

Specify original file path for source code references (excluding line number)

string optional
ignore-new

Specify that new assets will NOT be added to the project

boolean optional
ignore-existing

Specify that existing assets encountered in the file will NOT be updated

boolean optional
ignore-blank

Specify that blank translations should NOT be imported

boolean optional
tag-new

Tag any NEW assets added during the import with the given tags (comma separated)

string optional
tag-all

Tag ALL assets in the file with the given tags (comma separated)

string optional
untag-all

Remove existing tags from any assets matched in the imported file (comma separated)

string optional
tag-updated

Tag existing assets that are MODIFIED by this import

string optional
untag-updated

Remove existing tags from assets that are MODIFIED during import

string optional
tag-absent

Tag existing assets in the project that are NOT found in the imported file

string optional
untag-absent

Remove existing tags from assets NOT found in the imported file

string optional
delete-absent

Permanently DELETES project assets NOT found in the file (use with extreme caution)

boolean optional
flag-new

Set this flag on any NEW translations imported into the current locale

string optional
flag-updated

Set this flag on any translations MODIFIED during import to the current locale

string optional
key

API key - required if not sent in Authorization header

string optional

Request body

The POST request body must contain (string) Raw source of file being imported.

Loco's official SDK binds the request body to the "data" parameter. Check the documentation for other libraries.

Request headers

Authorization

API key sent as "Loco <key>" or "Basic <encoded>". See Authentication.

string required if not in query

Response

A single JSON-encoded ImportResult object, which takes the following form:

{
    "status": 200, // Whether import was synchronous (200) or asynchronous (201)
    "message": "", // Summary of import result
    "locales": [
        {
            "code": "", // Locale short code, or language tag
            "name": "", // Friendly display name
            "source": false, // Whether the default/source locale of the project
            "plurals": {
                "length": 2, // Number of forms including singular
                "equation": "n != 1", // Equation for calculating offset in forms
                "forms": ["zero","one","two","few","many","other"], // Plural form names
            },
            "progress": {
                "translated": 0, // Number of assets for which a translation exists (including those flagged)
                "untranslated": 0, // Number of assets that are not yet translated to this language
                "flagged": 0, // Number of translations that are flagged as requiring attention
                "words": 0, // Approximate word count for translated texts in this language
            }
        }
    ]
}  

Try it

Open in test console »


« /api/import