Skip to content

Translate: Empty rich text Lexical fields are not translated when using emptyOnly option #111

@jhb-dev

Description

@jhb-dev

When using the "only translate empty fields" option, rich text Lexical fields that are empty (but not undefined) are not translated.

The traverseField function only checks whether a rich text field is defined, but it does not verify if the field is empty. A rich text field can become empty when it previously had content but was later cleared via the UI. In such cases, the field is stored in the database with the following JSON structure:

{
  "root": {
    "children": [
      {
        "children": [],
        "direction": null,
        "format": "",
        "indent": 0,
        "type": "paragraph",
        "version": 1,
        "textFormat": 0,
        "textStyle": ""
      }
    ],
    "direction": null,
    "format": "",
    "indent": 0,
    "type": "root",
    "version": 1
  }
}

Since the field is not undefined, it is not considered empty, and therefore, it does not get translated when the emptyOnly option is enabled.

Expected Behavior: Rich text fields that are effectively empty (i.e., contain no user-entered content) should be considered empty and translated when using the emptyOnly option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions