Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested objects in translation files #153

Open
kahurangitama opened this issue Jan 12, 2020 · 0 comments
Open

Nested objects in translation files #153

kahurangitama opened this issue Jan 12, 2020 · 0 comments

Comments

@kahurangitama
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant