# I18n - custom error message with interpolation

**URL:** <https://jsonforms.discourse.group/t/i18n-custom-error-message-with-interpolation/2475>\
**Category:** General\
**Created:** [November 28, 2024, 2:57pm UTC](https://jsonforms.discourse.group/t/i18n-custom-error-message-with-interpolation/2475 "2024-11-28T14:57:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pegu](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@pegu](https://jsonforms.discourse.group/u/pegu)\
**Post date:** [November 28, 2024, 2:57pm UTC](https://jsonforms.discourse.group/t/i18n-custom-error-message-with-interpolation/2475/1 "2024-11-28T14:57:11Z")

</div>

Hello There 🙂

I want to customize error messages with i18n, but I have no idea how to deal with interpolation. Is something like that `{{minLength}}` based on property’s schema value possible?

```auto
  const translate = (key: string, defaultMessage: string, args: any) => {
    const translations = {
      error: {
        required: 'is required',
        minLength: `should have at least {{minLength}} characters`,
      },
    };

    return get(translations, key) ?? defaultMessage;
  };

  return (
      <JsonForms
        schema={schema}
        uischema={uiSchema}
        data={data}
        renderers={renderers}
        cells={cells}
        onChange={handleOnChange}
        ajv={ajv}
        i18n={{ translate }}
      />

```

Or is there other way to handle this kind of error messages customization?  
Thanks for help in advance 🙂

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [November 29, 2024, 7:08am UTC](https://jsonforms.discourse.group/t/i18n-custom-error-message-with-interpolation/2475/2 "2024-11-29T07:08:32Z")

</div>

Hi @pegu,

There is no built-in templating support in JSON Forms. This is the responsibility of the translators.

Note that specifically for errors you can instead also hand over a `translateError` method, see [here for the docs](https://jsonforms.io/docs/i18n#translateerror). This method is called on all errors and has full access to the AJV `ErrorObject`, so you can for example determine the `minLength`.
