Skip to content

Nested objects in translation files #153

@kahurangitama

Description

@kahurangitama

Hi there!
Normally people have translations file like:

{
  "Form.Login.Input.Label": "...",
  "Form.Login.Input.Placeholder": "..."
}

but the part "Form.Login.Input" is duplicated each time we need to group translations logically.
To avoid this duplication I decided to have just an object (not plain) as my translation file structure like:

{
  "Common": {
    "Button": {
      "AddStep": "add step",
      "Back": "Back",
      "Continue": "Continue",
      "Create": "Create",
      "Delete": "Delete",
      "Edit": "Edit",
      "Order": "Order",
      "Save": "Save",
      "Submit": "Submit",
      "Update": "Update"
    }
  },
  "Form": {
    "Address": {
      "Header": {
        "Address": "Delivery address",
        "Contact": "Contact details"
      },
      "Label": {
        "Apartment": "Apartment",
        "Building": "Building",
        "City": "City",
        "Country": "Country",
        "Entrance": "Entrance",
        "Floor": "Floor",
        "Name": "Name",
        "Phone": "Phone",
        "Street": "Street"
      }
    },
  ........

I just stumbled upon this plugin, install it as it described and got all my keys deleted:

> node ./translationRunner.js

Duplicate ids:
 
  No duplicate ids found, great!
 
Maintaining en.json:
 
Deleted keys:
  Common: [object Object]
  Data: [object Object]
  Form: [object Object]
  Layout: [object Object]
  Modal: [object Object]
  Units: [object Object]
  View: [object Object]

My suggestion that is this plugin works only with plain translation files? If I wrong, could you point me, how to configure the script correctly?

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