Main menu

Loco Converter API

Convert between various language pack file formats with this simple Web API.

This is part of the full Loco API, but you're free to use it without an account.

Examples Supported formats Ask us something

Examples

Here are a few working examples in command line cURL. Try them out!

JSON structure to Gettext PO file.

Here we POST the JSON file source as the {src} field and specify the PO format as the file extension.

$ curl -F'src={"Apple":"Pomme"}' 'https://localise.biz/api/convert/json/messages-fr_FR.po'
# ...
msgid "Apple" 
msgstr "Pomme" 

Gettext PO file to multi-language YAML

Here we POST the file source from above as the raw request body and specify a specific YAML style with the {format} parameter.

$ curl --data-binary @messages-fr_FR.po 'https://localise.biz/api/convert/po/messages-fr_FR.yml?format=rails'
# ...
fr:
  Apple: Pomme

JSON to PHP with plural forms

This example shows the three plural forms of Polish exported to the PHP Zend format.

$ curl -F'src={"File":["Plik","Pliki","Pliko'\''w"]}' 'https://localise.biz/api/convert/json/example-pl.phps'
<?php
array (
  'File' =>
  array (
    0 => 'Plik',
    1 => 'Pliki',
    2 => 'Pliko\'w',
  ),
);

Endpoint

The basic format for the conversion endpoint is as follows:

POST https://localise.biz/api/convert/{from}/{name}.{ext}

Specifying locales

In most situations you'll want to specify a target locale for the exported file. You can do this in your file name, or separately as a query string parameter. The following are equivalent:

POST https://localise.biz/api/convert/json/messages-fr_FR.po
POST https://localise.biz/api/convert/json/messages.po?locale=fr_FR

In many cases you can leave out the {locale} parameter and get exactly what you expect. Simple key/value pairs may not require a locale, but notice how this behaviour changes when converting to file formats that contain multiple languages.

Alternative source locale

You can specify a non-English source locale with the {native} parameter, but this is only useful for some file formats. This example outputs a bi-lingual XLIFF file with French as the source-language and German as the target-language:

POST https://localise.biz/api/convert/json/messages-de.xlf?native=fr

Keys vs full texts

Some formats index translations by short keys, and others by full text strings. You can override Loco's defaults by specifying the {index} parameter as either text or id. This example ensures that the full text of the PO msgid fields are used as keys in JSON output:

POST https://localise.biz/api/convert/po/messages-fr.json?index=text

See the full API documentation for a more detailed explanation of parameters.

Source formats

The following source file formats can be converted by specifying the correct {from} parameter:

  • .po .pot .mo Gettext PO, POT and binary MO
  • .ts TS for Qt Framework
  • .tmx Translation Memory eXchange
  • .xlf Localisation Interchange File Format
  • .resx ResX for .NET framework
  • .plist .blist Apple property list and binary plist
  • .strings iOS Localizable strings
  • .properties Java properties file

Other, more generic file formats are supported too. Loco will parse the following types as long as they're in the style of one of the export formats.

  • yml Flat and nested YAML structures, used by Symfony and Rails respectively.
  • xml XML including Android strings, Java properties and Tizen format
  • php PHP source code, or a specific language pack for Symfony, Zend and CodeIgniter
  • json JSON structures including plural support.

If Loco fails to parse your source file please let us know, because we'd like to support anything you can throw at it.

Target formats

The following language pack formats can be exported by specifying the relevant file extension:

  • .pot .po .mo Gettext PO, POT and binary MO
  • .tmx Translation Memory eXchange
  • .xlf .xliff Localisation Interchange File Format
  • .csv Comma separated values
  • .sql MySQL INSERT statements
  • .resx ResX for .NET framework
  • .html HTML table
  • .strings iOS Localizable strings
  • .stringsdict iOS plural rules
  • .plist .bplist Apple property list XML and binary formats
  • .properties Java properties file
  • .ts TS, an XML format for Qt Framework

The following extensions are used for mutiple formats, but have a default:

Alternative styles

The {format} parameter can be used to export a more specific style of some of the formats above –

JSON and JavaScript formats

In addition to the default JSON format, you can specify Chrome or i18next language pack formats as follows

https://localise.biz/api/convert/{from}/{name}.json?format=chrome
https://localise.biz/api/convert/{from}/{name}.json?format=i18next

In addition to the default JavaScript function you can specify output for gettext.js or Angular Gettext.

https://localise.biz/api/convert/{from}/{name}.js?format=gettext
https://localise.biz/api/convert/{from}/{name}.js?format=ng-gettext

YAML formats

Several YAML formats are available - simple, nested and rails. The simple format is flat and only exports a single locale. The nested format supports multiple locales and contains a top-level namespace.

The rails format is specifically for Ruby on Rails and follows the conventions of the i18n module.

https://localise.biz/api/convert/{from}/{name}.yml?format=rails
https://localise.biz/api/convert/{from}/{name}.yml?format=nested

XML formats

In addition to the default Android format, specify java to produce Java properties XML and tizen to produce Tizen formatted XML.

https://localise.biz/api/convert/{from}/{name}.xml?format=java
https://localise.biz/api/convert/{from}/{name}.xml?format=tizen

Other XML formats have their own specific file extensions, such as .tmx .xlf .resx .plist .ts

iOS Localization files

In addition to the strings and stringsdict extensions, you can export an iOS-specific XLIFF file suitable for XCode's "Import Localizations" feature:

https://localise.biz/api/convert/{from}/{name}.xliff?format=xcode

PHP language packs

In addition to the default Zend format, you can specify Symfony or Code Igniter or output simple constant definitions.

https://localise.biz/api/convert/{from}/{name}.phps?format=symfony
https://localise.biz/api/convert/{from}/{name}.phps?format=codeigniter
https://localise.biz/api/convert/{from}/{name}.phps?format=constants

Note that the .phps extension is used to indicate source code output, but you can use .php if you prefer.

Authentication and rate limiting

There are currently no rate limits and no authentication is required for the /convert API endpoints.

Please read the terms of use before using this API.

Powered by Loco

Loco takes the pain away from developing multi‑language apps.

Sign up for free Find out more