Localize label

Hi team,

I am using React with jsonforms. Are there any way that I can localize the label text in schema.json?

[original thread by Huy Dang]

[Benjamin Börngen-Schmidt]

it is not possible to have it in the schema, but you can overwrite labels in the uiSchema. There is an example here: jsonforms/util.tsx at master · eclipsesource/jsonforms · GitHub

Hi @benjamin-b-s(benjamin-b-s), that’s not completely correct :wink: We often localize via JSON Schemas.

At the moment the title of the controls are determined this way:

  1. If there is a label in the UI schema, then this is used, e.g. { type: ‘Control’, scope: ‘#/properties/name’, label: ‘Nombre’ } would result in the label Nombre

  2. If not, then the title in the JSON Schema is rendered, e.g. name: { type: ‘string’, title: ‘Nom’ } produces the label Nom

  3. If both don’t exist then we take the property name from the JSON Schema and do some separation and upper casing, e.g. name: { type: ‘string’ } produces the label Name.

Therefore for localization purposes we currently use one of two approaches:
Either exchange the JSON Schema with localized title attributes and don’t use any labels in UI Schemas, or exchanging the UI Schema with the proper labels.

Note that we’re looking into a more generalized approach for one of the next versions of JSON Forms.

As this post is still quite popular: JSON Forms now has built-in i18n support. See here for the documentation.