rjsf-team/react-jsonschema-form

Localization

olzraiti opened this issue · 7 comments

Currently there is no way to localize the form (add/remove/submit -buttons, error messages).
Localizations could be in a separate schema (example below). This would allow uniform localization technique for fields provided by the form and also custom schema fields. However, this wouldn't provide a way to localize error messages. Maybe a error message formatter function could be given to the form as a parameter.

jsonSchema:

{type: "object",
 properties: {
     custom: {
         type: "object",
         properties: { ... }
     },
     array: {
          type: "array",
          items: { ... }
      }
 }
}

uiSchema:

{
 custom: {
     "ui:field": someField
 }
}

localizationschema:

{
    array: {
        add: "localized add text",
        delete: "localized delete text"
    }, custom: {
        { ... }
    }
}

Or could we add dependency to something like https://github.com/yahoo/react-intl and pass in the translations in the form properties?

After #285 is merged, the only thing that can't be localized are the jsonschema validations.

The jsonschema validations can be localized by inspecting the ValidationError object that jsonschema.validate() returns (see: tdegrunt/jsonschema#147). In order to allow this lib's users to localize the jsonschema validations, it should be either possible to disable jsonschema validating so the users can do the validation themself, or provide a validation interceptor that would receive the ValidationError object that jsonschema returns.

@n1k0 : Would you accept a pull request if I wrote one? I'd like to have some feedback about my previous message, if I start working on this. :-)

n1k0 commented

@olzraiti sure, let's just polish and land #285 first, see my latest comments on the PR :)

i18n is quite important. I think react-intl integration would be the simplest.

Closed by #432

afeld commented

cc #739