Skip to content

What is the recommended approach to translate labels, descriptions, etc? #739

@bjbrewster

Description

@bjbrewster

Prerequisites

  • I have read the documentation;
  • In the case of a bug report, I understand that providing a SSCCE example is tremendously useful to the maintainers.

Description

I am attempting to implement label/description/help translation using react-intl in a custom FieldTemplate and am trying to get the path to the current field. I can almost use the id property like id.split('_').slice(1) except field names may have _ as part of their name, and the root id name can change (uiSchema["ui:rootFieldId"]) and may contain _ also.

Is there some other way to get the path to the current property? If not, can I request the id field separator in utils toIdSchema() and ArrayField be changed to a double underscore __ similar to BEM notation. So 'myroot__foo_bar__0__qux'.split('__').slice(1) would yield ['foo_bar', '0', 'qux']? This also works for field names that begin with a single underscore as sometimes used to denote private or reserved field names like in CouchDB _id and _deleted.

Perhaps this approach is completely flawed when taking into account definitions etc. Another approach may be to recursively traverse the schema object and definitions separately, building up the path as I go, and add a title, description and help attribute to each object property.

How are others translating the labels, field titles, descriptions, help text etc?

Steps to Reproduce

N/A

Expected behavior

N/A

Actual behavior

N/A

Version

0.51.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions