API Maker

The framework for AI era

Your code

Internationalization

Every error message in the language of the caller.

Create a language pack in API Maker and translate the messages you want: validation messages, system errors and the errors of your own custom APIs. A client sends x-am-internationalization with the name of the pack and gets its errors in that language.

See it live

Step through it, slow it down, or open the full canvas.

api-maker/features/internationalizationLive
  • Request
  • Pack
  • Translated
  • Fallback
Language
Defaultpack
Packs
5as many as you want
Code changes
0to translate
Restarts
0after an edit

Errors in the language of the caller. Send x-am-internationalization with the name of a language pack. The same request gets its error in English, Hindi, Spanish, Japanese or Chinese.

How it works

  1. Errors in the language of the caller.

    Send x-am-internationalization with the name of a language pack. The same request gets its error in English, Hindi, Spanish, Japanese or Chinese.

  2. A pack maps error codes to your words.

    Each system error has a code and a template. A pack gives your own template for the codes you want, in any script: Unicode just works.

  3. Missing translations never break.

    A code the pack does not have uses the Default English template, so a half done pack is already safe to use.

  4. Even field names read well.

    The COMMON map of a pack replaces words in the message data: cust_nm becomes customer name. A pack can also reword the English messages for a region.

  5. Your own API errors too.

    Errors your custom APIs return are listed in each pack to translate. Save a pack and the next request uses it: no restart.

What you get

Every kind of message

Message templates of API Maker, constant errors, and the errors your custom APIs list in their errorList.

Starts filled in

A new pack comes with every message in English. Translate the ones you need; the others keep working.

Field names too

The COMMON map of a pack replaces words inside messages, so cust_nm can read as customer name, in any language.

Any language, any script

Packs are plain text mappings, so Hindi, Japanese, Arabic or Chinese work like English.

An example

One backend, users in many countries

A mobile app sends the language of the phone in x-am-internationalization. Validation errors and the messages of your own APIs come back in that language, and the app shows them as they are.

A Spanish pack, with only what you changedes.ts
let mappings = {    COMMON: { cust_nm: 'nombre del cliente' },    AM_00001: { template: `Proporcione un campo '{field}' válido de tipo '{type}'.` },    CUSTOM_API_ERRORS: {        'No paid orders for this customer.': 'No hay pedidos pagados para este cliente.',    },};module.exports = mappings;

AM_00001 is the "required" message of the schema APIs. A new pack lists every key with its English text.

The client asks for Spanishrequest
POST /api/schema/admin/crm/main/customers/save-single-or-multiplex-am-authorization: <API user token>x-am-internationalization: es{ "email": "[email protected]" }

Good to know

  • Packs translate messages, not your data: the values stored in your tables are returned as they are.

Questions

What if the header is missing?

The default English messages are used.

How do my own errors get translated?

List them in the errorList of your custom API, throw them from your code, and give them a translation in the pack.