# Internationalization

> Answer the errors and messages of API Maker in the language of the caller - an i18n item maps every message to its translation, and the header x-am-internationalization picks it per request.

Source: https://docs.apimaker.dev/v1/docs/i18/i18.html

An i18n item is a dictionary : the messages of API Maker and of your custom APIs on the left, their text in a language on the right. A request names the item in a header and gets its errors and messages translated.

| | |
|---|---|
| Page | `Utility → Internationalization` : a name and a TypeScript file which exports the dictionary. |
| Header | `x-am-internationalization: <name of the item>` (its id works too). Without it, the messages are the ones of API Maker. |
| Translates | The constant errors of API Maker (validation, authorization, not found…), the `errorList` of your [custom APIs](https://docs.apimaker.dev/v1/docs/settings/customApiSettings.html), the errors of third party APIs. |
| Placeholders | A constant error keeps its `{field}`, `{value}`… placeholders in the translation. |

## 1. Create the item

**hindi**

```typescript
module.exports = {
    // constant errors of API Maker : keep the placeholders
    "Please provide valid '{field}' field with type '{type}'.": "कृपया '{field}' फ़ील्ड का सही मान दें ({type}).",
    "You are not authorized to access this API.": "आपको इस API की अनुमति नहीं है।",

    // the errorList of your custom APIs
    "Unable to process this request.": "यह अनुरोध पूरा नहीं हो सका।",
};
```

- The page lists the constant messages of API Maker to start from, and every message named in the `errorList` of a custom API.

## 2. Throw the message

**Custom API**

```typescript
throw new Error('Unable to process this request.');
```

## 3. Ask for the language

```text
POST /api/custom-api/admin/customers
x-am-internationalization: hindi
```

```json
{ "success": false, "statusCode": 500, "errors": [ { "code": 500, "message": "यह अनुरोध पूरा नहीं हो सका।" } ], "warnings": [] }
```

- A message the item does not have is answered as it is.
- i18n items go to Git.

## Related

- [Custom API settings](https://docs.apimaker.dev/v1/docs/settings/customApiSettings.html) · [Request headers](https://docs.apimaker.dev/v1/docs/apis-all/header/requestHeader.html) · [Error codes](https://docs.apimaker.dev/v1/docs/apis-all/error-codes.html)
