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=nested'
# ...
fr_FR:
  messages:
    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

No target locale

There may be cases where specifying a target locale makes no sense. For example Gettext POT files have only a source strings and an empty target. In that case, just leave the locale parameter out:

POST https://localise.biz/api/convert/json/messages.pot

Native locale

You can specify a non-English source locale with the {native} parameter, but this does nothing in a lot of cases. This example outputs a bi-lingual XLIFF file with French as the native language:

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

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 Gettext PO
  • mo Gettext binary MO
  • ts TS for Qt Framework
  • tmx Translation Memory eXchange
  • xlf Localisation Interchange File Format
  • resx ResX for .NET framework
  • 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:

  • .po Gettext PO
  • .mo Gettext binary MO
  • .ts TS for Qt Framework
  • .tmx Translation Memory eXchange
  • .xlf Localisation Interchange File Format
  • .csv Comma separated values
  • .sql MySQL INSERT statements
  • .resx ResX for .NET framework
  • .html HTML table
  • .strings iOS Localizable strings
  • .properties Java properties file

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

  • .js Simple JavaScript lookup function
  • .yml Flat YAML structure suitable for Symfony
  • .xml XML, defaults to Android strings
  • .phps PHP source, defaults to array format suitable for Zend Framework
  • .json Simple JSON structure

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 the Chrome language pack format as follows

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

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

https://localise.biz/api/convert/{from}/{name}.js?format=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, XLIFF, ResX and TS.

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 extension phps is used instead of php. This is an internal limitation of the Loco servers. We can live with it if you can.

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