{"_id":"@codemayonnaise/extract-react-intl-messages","name":"@codemayonnaise/extract-react-intl-messages","dist-tags":{"latest":"4.1.2"},"versions":{"4.1.2":{"name":"@codemayonnaise/extract-react-intl-messages","version":"4.1.2","description":"Extract react-intl messages","license":"MIT","repository":{"type":"git","url":"git+https://github.com/akameco/extract-react-intl-messages.git"},"author":{"name":"akameco","email":"akameco.t@gmail.com","url":"https://akameco.github.io"},"engines":{"node":">=10"},"main":"dist/index.js","scripts":{"fmt":"prettier --write .","example":"./cli.js -l=en,ja -o example/i18n -d en 'example/**/*.{js,tsx}'","example:yaml":"./cli.js -l=en,ja -f=yaml -o example/i18n -d en 'example/**/*.{js,tsx}'","prepublish":"npm run build","build":"tsc","lint":"eslint src/**/*.ts --fix --cache","test":"jest"},"bin":{"extract-react-intl-messages":"dist/cli.js","extract-messages":"dist/cli.js"},"keywords":["react","i18n","intl","react-intl","extract","json","messages"],"dependencies":{"@babel/core":"^7.9.0","ajv":"^6.9.1","babel-plugin-react-intl":"^7.0.0","flat":"^5.0.0","glob":"^7.1.6","js-yaml":"^3.13.1","load-json-file":"^6.2.0","lodash.merge":"^4.6.2","lodash.mergewith":"^4.6.2","lodash.pick":"^4.4.0","meow":"^6.1.0","mkdirp":"^1.0.3","pify":"^5.0.0","read-babelrc-up":"^1.1.0","sort-keys":"^4.0.0","write-json-file":"^4.3.0"},"devDependencies":{"@akameco/tsconfig":"^0.4.0","@babel/plugin-proposal-class-properties":"^7.8.3","@babel/preset-env":"^7.9.0","@babel/preset-flow":"^7.9.0","@babel/preset-react":"^7.9.1","@types/flat":"^5.0.0","@types/glob":"^7.1.1","@types/jest":"^25.1.4","@types/js-yaml":"^3.12.2","@types/lodash.merge":"^4.6.6","@types/lodash.mergewith":"^4.6.6","@types/lodash.pick":"^4.4.6","@types/mkdirp":"^1.0.0","@types/pify":"^3.0.2","@types/temp-write":"^4.0.0","babel-core":"7.0.0-bridge.0","babel-plugin-react-intl-auto":"^3.2.0","eslint":"^6.8.0","eslint-config-precure":"^5.3.1","husky":"^4.2.3","jest":"^25.1.0","lint-staged":"^10.0.9","prettier":"^2.0.2","react":"^16.13.1","react-intl":"^4.2.2","temp-write":"^4.0.0","tempy":"^0.5.0","ts-jest":"^25.2.1","typescript":"^3.8.3"},"lint-staged":{"*.{ts}":["prettier --write","eslint --fix"],"*.{js,json,md}":["prettier --write"]},"husky":{"hooks":{"pre-commit":"lint-staged"}},"types":"./dist/index.d.ts","gitHead":"f6fa401fb63b199a01ec0fb03864327c20d021de","bugs":{"url":"https://github.com/akameco/extract-react-intl-messages/issues"},"homepage":"https://github.com/akameco/extract-react-intl-messages#readme","_id":"@codemayonnaise/extract-react-intl-messages@4.1.2","_nodeVersion":"18.14.2","_npmVersion":"9.5.0","dist":{"integrity":"sha512-qAF2v/cFH4cBUsvBZkeq6qtWV6lP8Y2xYsV6dNSH5LClK4d1e4GjVY7Di99hmSJUkK/OeQHGjy3L0B7Uil0qvg==","shasum":"993c941ba6ee98c582b73619671bff31ddc0fdd9","tarball":"https://registry.npmjs.org/@codemayonnaise/extract-react-intl-messages/-/extract-react-intl-messages-4.1.2.tgz","fileCount":24,"unpackedSize":54060,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEzzStKR2UPcuRdv1DCl9yvH1hTG/8Sob0tZ2U6bA77PAiEAimMYwTia/KyCvqH36dH4l9KCsQpavtvDgPuLdlujhX8="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkCITLACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp6vQ//ZLuUKfpPdUXOiKZlO2pm4WNwPaFivDG0EBlYSCz5qP1r9SHc\r\n8ahdULugco0CFn24Ps7yIMD4kCWsRUjZGUN6eRNaAPD2YMngMt9wXyB+N/Ca\r\njiVOLdZ8VOoLhkBbdAyTx9n6V3QWIWfbbfrB+yx3TdzUwnT5qqMegQIq7cgm\r\nv5dTLfzOQCnM40a0hfOBKZEsV3x+uY+eTt15pULDphjZLf4shcGlbfEfH0uz\r\n4wXM1gOE/N8wj7y67wdcxwshxo/7x0Ip+ruUF1nJCZQY29rRtsj0rFToeGQ6\r\nvRTJKqcjDcEXuT6wOCRx/ATdEjZLXwMvcWspcUb7ydwcvSVTusCTVudKFoDB\r\n62vvU6raSuxvRZgGJq/iTYbHBbgFZWlrVb0A48tJxTx/8Z6mY5zFXD8sDdWu\r\n4ZIoFXCxsx290CVyf3AOeVVCFSwgVSdEjPH3SJ3CQcoF5H1EfBN7dc3MgObH\r\nyF+fEDtwissf8i3ma7TOBwpHvAx90MNwObK0kXk15hHqEdxhBTtaqz2Zlo1i\r\ncIyExsuOmO89Lbz02+lWjjB15xC0a6aGB7jn9WO4pHrNOPeOd8MMtSYOzike\r\nn82tQhEvR+6oYxdVTzkXDzugOc/R4YV9h8WpdfzMvsLJoIlrta127Reh7Mrq\r\n436cCtVulAteBTUXXMwK06W4g14kKXuKmuo=\r\n=p2F/\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"codemayonnaise","email":"christopher.tokar@ibm.com"},"directories":{},"maintainers":[{"name":"codemayonnaise","email":"christopher.tokar@ibm.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/extract-react-intl-messages_4.1.2_1678279883257_0.8130421969489712"},"_hasShrinkwrap":false}},"time":{"created":"2023-03-08T12:51:23.181Z","4.1.2":"2023-03-08T12:51:23.510Z","modified":"2023-03-08T12:51:23.698Z"},"maintainers":[{"name":"codemayonnaise","email":"christopher.tokar@ibm.com"}],"description":"Extract react-intl messages","homepage":"https://github.com/akameco/extract-react-intl-messages#readme","keywords":["react","i18n","intl","react-intl","extract","json","messages"],"repository":{"type":"git","url":"git+https://github.com/akameco/extract-react-intl-messages.git"},"author":{"name":"akameco","email":"akameco.t@gmail.com","url":"https://akameco.github.io"},"bugs":{"url":"https://github.com/akameco/extract-react-intl-messages/issues"},"license":"MIT","readme":"# extract-react-intl-messages\n\n[![test](https://github.com/akameco/extract-react-intl-messages/workflows/test/badge.svg)](https://github.com/akameco/extract-react-intl-messages/actions?query=workflow%3Atest)\n[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![MIT License](https://img.shields.io/npm/l/nps.svg?style=flat-square)](./license)\n[![All Contributors](https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square)](#contributors-)\n\nThis package will generate json or yaml files from a glob. It will generate one file per locale, with the ids of each message defined by the [`defineMessages`](https://github.com/yahoo/react-intl/wiki/API#definemessages) function of [react-intl](https://github.com/yahoo/react-intl). The value of each of these keys will be an empty string, except for your `defaultLocale` which will be populated with the [`defaultMessage`](https://github.com/yahoo/react-intl/wiki/API#message-descriptor).\n\n## Dependencies\n\n### Babel\n\n- 0.x works with Babel 6\n\n## Install\n\n```\n$ npm install --save-dev extract-react-intl-messages\n```\n\n## Usage\n\napp/components/App/messages.js\n\n```js\nimport { defineMessages, useIntl } from 'react-intl'\n\nexport default defineMessages({\n  hello: {\n    id: 'a.hello',\n    defaultMessage: 'hello'\n  },\n  world: {\n    id: 'a.world',\n    defaultMessage: 'world'\n  }\n})\n\nexport const SubmitButton = () => {\n  const intl = useIntl()\n  const label = intl.formatMessage({\n    id: 'a.submit',\n    defaultMessage: 'Submit Button'\n  })\n  return <button aria-label={label}>{label}</button>\n}\n```\n\n### Run Script\n\n```\n$ extract-messages -l=en,ja -o app/translations -d en --flat false './app/**/!(*.test).js'\n```\n\n### Output\n\napp/translations/en.json\n\n```json\n{\n  \"a\": {\n    \"hello\": \"hello\",\n    \"world\": \"world\",\n    \"submit\": \"Submit Button\"\n  }\n}\n```\n\napp/translations/ja.json\n\n```json\n{\n  \"a\": {\n    \"hello\": \"\",\n    \"world\": \"\",\n    \"submit\": \"\"\n  }\n}\n```\n\n## Recommend\n\nUse with [babel-plugin-react-intl-auto: i18n for the component age. Auto management react-intl ID.](https://github.com/akameco/babel-plugin-react-intl-auto)\n\n## CLI\n\n```console\n$ extract-messages --help\n\n  Extract react-intl messages\n\n  Usage\n  $ extract-react-intl-messages <input>\n  $ extract-messages <input>\n\n  Options\n  -o, --output            Output directory [require: true]\n  -l, --locales           locales [require: true]\n  -f, --format            json | yaml [default: json]\n  -d, --defaultLocale     default locale\n  --overwriteDefault      default: false\n  --flat                  json [default: true] | yaml [default: false]\n\n  Example\n  $ extract-messages --locales=ja,en --output app/translations 'app/**/*.js'\n  $ extract-messages -l=ja,en -o i18n 'src/**/*.js'\n  $ extract-messages -l=ja,en -o app/translations -f yaml 'app/**/messages.js'\n```\n\n### create-react-app user\n\ncreate `.babelrc` like this.\n\n```json\n{\n  \"presets\": [\"react-app\"]\n}\n```\n\nRun with `NODE_ENV=development`.\n\n```\n$ NODE_ENV=development extract-messages ...\n```\n\n### TypeScript\n\nbabel required.\n\nSee [example/with-typescript](example/with-typescript)\n\n```\nnpm install --save-dev @babel/core @babel/preset-typescript @babel/preset-react\n```\n\n`babel.config.js`\n\n```js\nmodule.exports = function (api) {\n  api.cache(true)\n\n  return {\n    presets: ['@babel/preset-react', '@babel/preset-typescript']\n  }\n}\n```\n\n## API\n\n### extractReactIntlMessages(locales, input, buildDir, [options])\n\n#### locales\n\nType: `Array<string>`\n\nExample: `['en', 'ja']`\n\n#### input\n\nType: `Array<string>`\n\nTarget files.\nglob.\n\n#### buildDir\n\nType: `string`\n\nExport directory.\n\n#### options\n\n##### defaultLocale\n\nType: `string`<br>\nDefault: `en`\n\n##### format\n\nType: `json` | `yaml`<br>\nDefault: `json`\n\nSet extension to output.\n\n##### overwriteDefault\n\nType: `boolean`<br>\nDefault: true\n\nIf overwriteDefault is `false`, it will not overwrite messages in the default locale.\n\n##### flat\n\nType: `boolean`<br>\nDefault: `true`\n\nIf format is `yaml`, set to `false`.\n\nBe careful if `false`.\nSee [this issue](https://github.com/akameco/extract-react-intl-messages/issues/3).\n\n##### babel-plugin-react-intl's Options\n\nSee https://github.com/formatjs/formatjs/tree/master/packages/babel-plugin-react-intl#options\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n  <tr>\n    <td align=\"center\"><a href=\"http://akameco.github.io\"><img src=\"https://avatars2.githubusercontent.com/u/4002137?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>akameco</b></sub></a><br /><a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=akameco\" title=\"Code\">💻</a> <a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=akameco\" title=\"Tests\">⚠️</a> <a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=akameco\" title=\"Documentation\">📖</a> <a href=\"#infra-akameco\" title=\"Infrastructure (Hosting, Build-Tools, etc)\">🚇</a></td>\n    <td align=\"center\"><a href=\"http://hoantran.info\"><img src=\"https://avatars3.githubusercontent.com/u/13161875?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Hoan Tran</b></sub></a><br /><a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=hoantran-it\" title=\"Code\">💻</a> <a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=hoantran-it\" title=\"Tests\">⚠️</a></td>\n    <td align=\"center\"><a href=\"https://github.com/giantpinkwalrus\"><img src=\"https://avatars1.githubusercontent.com/u/3383240?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>giantpinkwalrus</b></sub></a><br /><a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=giantpinkwalrus\" title=\"Code\">💻</a></td>\n    <td align=\"center\"><a href=\"https://github.com/enrique-ramirez\"><img src=\"https://avatars3.githubusercontent.com/u/1190640?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>enrique-ramirez</b></sub></a><br /><a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=enrique-ramirez\" title=\"Documentation\">📖</a></td>\n    <td align=\"center\"><a href=\"http://stefan-gojan.de\"><img src=\"https://avatars2.githubusercontent.com/u/163128?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Stefan Gojan</b></sub></a><br /><a href=\"https://github.com/akameco/extract-react-intl-messages/issues?q=author%3Ahoschi\" title=\"Bug reports\">🐛</a> <a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=hoschi\" title=\"Code\">💻</a> <a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=hoschi\" title=\"Tests\">⚠️</a></td>\n    <td align=\"center\"><a href=\"https://lithe.net\"><img src=\"https://avatars1.githubusercontent.com/u/857744?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Solomon English</b></sub></a><br /><a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=solomon23\" title=\"Code\">💻</a></td>\n    <td align=\"center\"><a href=\"https://github.com/Filson14\"><img src=\"https://avatars1.githubusercontent.com/u/4540538?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Filip \"Filson\" Pasternak</b></sub></a><br /><a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=Filson14\" title=\"Code\">💻</a></td>\n  </tr>\n  <tr>\n    <td align=\"center\"><a href=\"http://about.me/nodaguti\"><img src=\"https://avatars0.githubusercontent.com/u/27622?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>nodaguti</b></sub></a><br /><a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=nodaguti\" title=\"Code\">💻</a> <a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=nodaguti\" title=\"Tests\">⚠️</a></td>\n    <td align=\"center\"><a href=\"https://github.com/fix-fix\"><img src=\"https://avatars1.githubusercontent.com/u/11943024?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>fix-fix</b></sub></a><br /><a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=fix-fix\" title=\"Code\">💻</a></td>\n    <td align=\"center\"><a href=\"http://bradbarrow.com\"><img src=\"https://avatars3.githubusercontent.com/u/1264276?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>bradbarrow</b></sub></a><br /><a href=\"https://github.com/akameco/extract-react-intl-messages/issues?q=author%3Abradbarrow\" title=\"Bug reports\">🐛</a> <a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=bradbarrow\" title=\"Code\">💻</a> <a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=bradbarrow\" title=\"Tests\">⚠️</a></td>\n    <td align=\"center\"><a href=\"http://ddem.us/\"><img src=\"https://avatars1.githubusercontent.com/u/290457?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Gregor MacLennan</b></sub></a><br /><a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=gmaclennan\" title=\"Code\">💻</a></td>\n    <td align=\"center\"><a href=\"https://github.com/zarv1k\"><img src=\"https://avatars1.githubusercontent.com/u/6296643?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Dmitry Zarva</b></sub></a><br /><a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=zarv1k\" title=\"Code\">💻</a></td>\n    <td align=\"center\"><a href=\"https://github.com/panpanc\"><img src=\"https://avatars2.githubusercontent.com/u/29132669?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Michael Pan</b></sub></a><br /><a href=\"#example-panpanc\" title=\"Examples\">💡</a></td>\n    <td align=\"center\"><a href=\"https://github.com/testower\"><img src=\"https://avatars2.githubusercontent.com/u/231492?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Tom Erik Støwer</b></sub></a><br /><a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=testower\" title=\"Code\">💻</a></td>\n  </tr>\n  <tr>\n    <td align=\"center\"><a href=\"https://nextbook.io\"><img src=\"https://avatars0.githubusercontent.com/u/20876627?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Bart Lens</b></sub></a><br /><a href=\"https://github.com/akameco/extract-react-intl-messages/commits?author=lensbart\" title=\"Code\">💻</a></td>\n    <td align=\"center\"><a href=\"https://github.com/revskill10\"><img src=\"https://avatars3.githubusercontent.com/u/1390196?v=4\" width=\"100px;\" alt=\"\"/><br /><sub><b>Truong Hoang Dung</b></sub></a><br /><a href=\"#example-revskill10\" title=\"Examples\">💡</a></td>\n  </tr>\n</table>\n\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!\n\n## License\n\nMIT © [akameco](http://akameco.github.io)\n","readmeFilename":"readme.md"}