# Translation File Converter (i18n) API

> Convert translation files between JSON, XLIFF 1.2 / 2.0, PO, ARB, iOS .strings, Android XML, .resx, YAML, CSV; find missing keys; pseudo-locales.

- Endpoint: `POST https://apibox.io.vn/v1/i18n-convert`
- Category: Developer utilities
- HTML docs: https://apibox.io.vn/docs/i18n-convert/ (Vietnamese: https://apibox.io.vn/vi/docs/i18n-convert/)
- Online tool: https://apibox.io.vn/tools/i18n-convert/
- Authentication: `Authorization: Bearer <API key>` or `X-API-Key: <API key>` (free key: https://apibox.io.vn/dashboard/#signup)

Read and write the common localisation formats through one model (key, value, plural forms, note, context, source text): JSON flat or nested (i18next, vue-i18n, with `_one` / `_other` plural suffixes), ARB (Flutter, `@key` descriptions, ICU plurals), XLIFF 1.2 and 2.0 (inline tags kept), gettext PO / POT (context, plurals, translator comments), iOS `.strings`, Android `strings.xml` (`string`, `plurals`, `string-array`, escapes), .NET `.resx`, Rails YAML and CSV for translators. `from` is detected from the content; set `to` and the target `locale`.

`action=diff` compares a `base` file with one `translation` or several `translations` ({ "vi": …, "ja": … }) and lists missing, extra, untranslated and unchanged keys, placeholder mismatches (`{name}`, `{{name}}`, `%s`, `%1$d`, `%{name}`, `${name}`, ICU arguments), HTML tag mismatches and ICU MessageFormat syntax errors (e.g. a plural without `other`), with a coverage percentage. `action=pseudo` makes a pseudo-locale (accented, ~35 % longer, bracketed, placeholders and tags untouched) to find hard-coded strings and truncation. `action=parse` returns the entries.

Pass `source` (the source-language file) to fill XLIFF `<source>` and PO `msgid` with real text. `download=true` returns the file itself. Up to 5 MB and 50,000 keys.

## Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| `content` | body | string | yes |  | The translation file (text, multipart `file` or raw body). For diff: `base`. |
| `action` | body | string | no | `convert` | `convert`, `parse`, `diff` or `pseudo` (alias `op`). |
| `from` | body | string | no | `auto` | Input format: `json`, `json-nested`, `arb`, `xliff12`, `xliff20`, `po`, `strings`, `android`, `resx`, `yaml`, `csv`. |
| `to` | body | string | no |  | Output format (same list). |
| `locale` | body | string | no |  | Target locale written into the file (XLIFF, ARB, PO, YAML). |
| `source` | body | string | no |  | Source-language file: real text for XLIFF `<source>` / PO `msgid`. |
| `translation` | body | string | no |  | diff: one translation file; or `translations` { lang: file }. |
| `download` | body | boolean | no | `false` | Return the converted file instead of JSON. |

## Example request

```bash
curl -X POST "https://apibox.io.vn/v1/i18n-convert" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"content":"{\"home\":{\"title\":\"Welcome, {{name}}!\",\"items_one\":\"{{count}} item\",\"items_other\":\"{{count}} items\"}}","to":"po","locale":"vi"}'
```

## Example response

```json
{
  "from": "json-nested",
  "to": "po",
  "locale": "vi",
  "count": 2,
  "warnings": [],
  "output": "msgid \"\"\nmsgstr \"\"\n\"Content-Type: text/plain; charset=UTF-8\\n\"\n\"Language: vi\\n\"\n\"MIME-Version: 1.0\\n\"\n\"Content-Transfer-Encoding: 8bit\\n\"\n\n#: home.title\nmsgid \"home.title\"\nmsgstr \"Welcome, {{name}}!\"\n\n#: home.items\nmsgid \"home.items\"\nmsgid_plural \"home.items\"\nmsgstr[0] \"{{count}} item\"\nmsgstr[1] \"{{count}} items\"\n"
}
```

## Use cases

- Send app strings to translators as XLIFF or CSV and import them back
- Move a React i18next project to Flutter ARB or Android strings.xml
- Check in CI that every language has all keys and matching placeholders
- Generate a pseudo-locale to test UI truncation before real translation

## FAQ

### Are plurals converted?

Yes: i18next suffixes, Android plurals, PO msgstr[n], Rails one / other and ICU plural messages map onto each other. Formats without plurals (.strings, .resx) get the ICU text and a warning.

### What does the PO msgid contain?

The source text when you pass source (or the file already has it), otherwise the key. msgctxt is kept.

### Is .mo supported?

No, send the .po source. Compiled .mo files are refused with a clear error.
