1.0.5 • Published 5 years ago

react-intl-json-macro v1.0.5

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

react-intl-macro-json

npm package

When creating new keys for react-intl elements in your application, this package allows users to enter new key:value into CLI to write to react-intl json files and sort.

Install

npm install react-intl-json-macro

Setup

  1. In your package.json, add a script similiar to the following:

    "scripts": {

    "add:intlMessage": "node node_modules/react-intl-json-macro [JSON file directory location]"

    }

  • For example: "add:intlMessage": "node node_modules/react-intl-json-macro './src/i18n/locales'"
  • Only JSON files will be selected from the defined directory

Running Tool

  1. npm run add:intlMessage "KEY NAME" "MESSAGE NAME"
    For example: npm run add:intlMessage "header.subText" "default message text"
  2. All JSON files in the directory you have defined in the npm scripts will then be updated with the key:value pair you have executed. All keys in each JSON file will be alphabetized after the new key:value pair has been added.

Additional Notes

  • Installing Prettier will help keep the JSON files formatted nicely
  • Install: `npm install --save-dev prettier
  • Update npm scripts for prettier

    "scripts": {

    "pretty:json": "prettier --write './src/i18n/locales/*.json'"

    }

  • Run scripts together now
    npm run add:intlMessage "header.subText" "default message text" && npm run pretty:json

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago