Skip to content
This page View Markdown Open in ChatGPT Open in Claude

Internationalization

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, the errors of third party APIs.
Placeholders A constant error keeps its {field}, {value}… placeholders in the translation.

1. Create the item

hindi
1
2
3
4
5
6
7
8
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
throw new Error('Unable to process this request.');

3. Ask for the language

POST /api/custom-api/admin/customers
x-am-internationalization: hindi
{ "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.