{"_id":"@cabify/redux-polyglot","_rev":"7-7fceb97fa8d7e03096d9b8bbe69fbecc","name":"@cabify/redux-polyglot","dist-tags":{"beta":"0.9.0-beta","latest":"0.9.0"},"versions":{"0.8.1":{"name":"@cabify/redux-polyglot","version":"0.8.1","keywords":["polyglot","redux","react","i18n","reselect","component enhancer","translation"],"license":"MIT","_id":"@cabify/redux-polyglot@0.8.1","maintainers":[{"name":"cabify-dev","email":"npm@cabify.com"}],"homepage":"https://github.com/Tiqa/redux-polyglot","bugs":{"url":"https://github.com/Tiqa/redux-polyglot/issues"},"dist":{"shasum":"97842e13e3a8a6c3e20648adda769bdc8d8aee45","tarball":"https://registry.npmjs.org/@cabify/redux-polyglot/-/redux-polyglot-0.8.1.tgz","fileCount":16,"integrity":"sha512-HoEzFmxR0o9P/O7/fnFs3MMbg1rqQWJ/HGKJPqGJbQ7viYQcRfrBc+1oB+UopM+dVyd9XGAz053yhfnI4mSNig==","signatures":[{"sig":"MEUCIQCG7dBk9Qau5HslxcHqQkVxfUutiCLcZwimKSouYzsFQAIgZRYivSenijwHJBOJetqFqhY3hKc6EDCYsQQGlUMtVfo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":29291,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgP4pSCRA9TVsSAnZWagAA1zIP+wW8ik45GmbGSqMvzeIq\nAVEQ9sQhDuzm05Ol6ZA0oYtia2qAI4bwIuMHIYKCy6oyAUh51Dzh3itVM3d+\n4eMehXFxdclelnKvqs+4ofQP/DjWfV1n02qyCDNFQ38Rk534u5j4U4Ivc8rA\nkIVeRsPVcNY5aUy6Irp8dkov0F7mGd/miszRMGnXbNrayCai0wMVFKVrRbE9\nhVP+mnsNS0GTKEDD//TI3aLjVP6E2ixNMMMg87ee3S9cjaN7v9F7cw5oCkW7\nuALfcKbUpw5cUkovBvArI14wGDkSRYk6qcA5uBP3e3h7giXoO8+FClvw0cag\nznxR4QQNA+2G6JxihtWrViYH0g8fRtAlX7FctcpoZQ7OPDDLjvwqeJFYusML\nu6zvIvucyIjkyqzHWlIcvcHsevRAV74spcWLn5MYhRDM8LuC1lejFT7FZmMf\nsLitXGFtlU7L86+iqa74OETrsyG7UhXubGWU9Pdz+NqhMKLHRKK/21G7fo/o\nS1w0oFXXHUFaGjd+vXKVD+RTrfhlYujDNj08dL4bGRuOKNFZ0B4hTZTZe4yg\njOJEak0fGKndcPtVFYRG79cjCGZeloxiAuu07/rBzhCuvkEUiHEEcHt9KYHC\nd4Mq+5P8RX5u6w/yXYIUk9yoluWmS8PegWkXbGvlYTR0r7rHxCoeG/J7jq24\nGUic\r\n=4m60\r\n-----END PGP SIGNATURE-----\r\n"},"jest":{"roots":["src"],"testURL":"http://localhost","moduleFileExtensions":["js","jsx"],"coveragePathIgnorePatterns":["src/private/test/"],"setupTestFrameworkScriptFile":"./src/private/test/boot.js"},"main":"./dist/index.js","types":"./dist/types.d.ts","gitHead":"58f41fa2c232ed22602ba8d932b5963f2232b424","scripts":{"tw":"npm run test:watch","lint":"eslint --max-warnings 0 src","test":"jest --coverage","build":"babel src --out-dir dist --ignore '*.spec.js'","clean":"rimraf ./dist","test:all":"npm run -s prepublishOnly","test:watch":"jest --watch --coverage","postpublish":"echo --- PUBLISHED ---","prepublishOnly":"node scripts/prepublish.js"},"_npmUser":{"name":"cabify-dev","email":"npm@cabify.com"},"repository":{"url":"git+https://github.com/Tiqa/redux-polyglot.git","type":"git"},"_npmVersion":"6.14.8","description":"Tool for using Polyglot.js with Redux","directories":{},"_nodeVersion":"14.15.0","dependencies":{"redux":"^4.0.0","reselect":"^4.0.0","lodash.curry":"^4.1.1","lodash.assign":"^4.2.0","node-polyglot":"^2.3.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^22.4.3","ramda":"^0.25.0","react":"16.10.1","enzyme":"^3.10.0","eslint":"^4.19.1","rimraf":"^2.6.2","shelljs":"^0.8.1","webpack":"^4.6.0","babel-cli":"^6.26.0","react-dom":"^16.10.1","babel-core":"^6.26.3","babel-jest":"^22.4.3","prop-types":"^15.6.1","react-redux":"^7.1.1","babel-eslint":"^8.2.3","babel-register":"^6.26.0","babel-preset-env":"^1.6.1","redux-mock-store":"^1.5.1","babel-preset-react":"^6.24.1","eslint-plugin-react":"^7.7.0","react-test-renderer":"^16.3.2","@types/node-polyglot":"^0.4.31","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.11.0","eslint-plugin-jsx-a11y":"^6.0.3","enzyme-adapter-react-16":"^1.14.0","babel-plugin-transform-es2015-modules-umd":"^6.24.1","babel-plugin-transform-object-rest-spread":"^6.26.0"},"peerDependencies":{"react":">= 16.8.0","prop-types":"^15.6.1","react-redux":">= 7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/redux-polyglot_0.8.1_1614776913597_0.6486508610942157","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"0.8.2":{"name":"@cabify/redux-polyglot","version":"0.8.2","keywords":["polyglot","redux","react","i18n","reselect","component enhancer","translation"],"license":"MIT","_id":"@cabify/redux-polyglot@0.8.2","maintainers":[{"name":"cabify-dev","email":"npm@cabify.com"}],"homepage":"https://github.com/Tiqa/redux-polyglot","bugs":{"url":"https://github.com/Tiqa/redux-polyglot/issues"},"dist":{"shasum":"3aff98a4f96fda8da678ec4bb0a21d7bb2ce9624","tarball":"https://registry.npmjs.org/@cabify/redux-polyglot/-/redux-polyglot-0.8.2.tgz","fileCount":21,"integrity":"sha512-SIDEVTjABGI3XLRtvDvBr8J4hG+4wflwiCtjXG6NXGjeQPBjGFEn5YCPe+qor8IQZWgKYzRewofbwMgLiYVgSg==","signatures":[{"sig":"MEYCIQD1DXVH7VZxqGthilHYfK+DcGTaJUuBCv0V4Vm4hwF4RwIhAOCe1YDoLh0diegtz5CO7TSe8MUeVUm8/7RlGk03cbPQ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":529758,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgP4+zCRA9TVsSAnZWagAA8wgP/jIIuDay9CsSXoBsR7yC\nk5aMqObCRDTYaEyI/7uxgnWFpjgZNB0/u/r+jU03Bz0e06WPtvPgXCpkCfc4\nXtP6W5v6ODyB6DcIK+LSanqMVDRWBLVFmtUyHttftPsl7lsP6AnMRe5s+Cm9\nzc7F/E/YMcb6/c0gI2l8N6wJJ2I4pVkcKEuRSVGbbY7ZRDJmu/0p9146PgQD\n6u4FP1AmNgB5wLSD1VeUUK32DgwN3oVWbAlJIY0b+mjKak6KS3nAAPVY+ggv\njqFBpqnSfoECx6KA9hru30mBHOuhJeZTg9PSaN+Iy++FlrrvmpSSGU5zDdtp\nfNRGkyQeNMnWMwbI4iIKb4TcEMKIiDGLtAxPZ9f4oYmkkBpoRFfXrRucjTtd\n38n8zx2zstP07KPRFiJpkaaCqnk/ZRZCH16e/ZZVbWbIqOLwb6awbBAjLP5a\nwjcEFQSb6KiBKktJ1QdlCzXGVu2zlP+QE08vCxLzyz9gQVy6/8moRbU8drCF\nXh5nZNxdwO86RQanpEh8IWmi78N+mYtGG30UvheLe+/kBoTSoKQZxmqJ69bA\n/+JBSgBmlXMU6+3ZjapAOLxBJ7Cqfe+QizPKOpjojnPGW5xUaI/pZSohy7th\nBGDAJP3/dBs90VV+zoGtlDTYSACOCKaUUvROfkls3XVhIJEHhdnxxjqbuUZS\nmzKc\r\n=wgrd\r\n-----END PGP SIGNATURE-----\r\n"},"jest":{"roots":["src"],"testURL":"http://localhost","moduleFileExtensions":["js","jsx"],"coveragePathIgnorePatterns":["src/private/test/"],"setupTestFrameworkScriptFile":"./src/private/test/boot.js"},"main":"./dist/index.js","types":"./dist/types.d.ts","scripts":{"tw":"npm run test:watch","lint":"eslint --max-warnings 0 src","test":"jest --coverage","build":"babel src --out-dir dist --ignore '*.spec.js'","clean":"rimraf ./dist","publish":"npm publish --access public","test:all":"npm run -s prepublishOnly","test:watch":"jest --watch --coverage","postpublish":"echo --- PUBLISHED ---","prepublishOnly":"node scripts/prepublish.js"},"_npmUser":{"name":"cabify-dev","email":"npm@cabify.com"},"repository":{"url":"https://github.com/Tiqa/redux-polyglot.git","type":"git"},"description":"Tool for using Polyglot.js with Redux","directories":{},"licenseText":"The MIT License (MIT)\n\nCopyright (c) 2016 Guillaume ARM\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","dependencies":{"redux":"^4.0.0","reselect":"^4.0.0","lodash.curry":"^4.1.1","lodash.assign":"^4.2.0","node-polyglot":"^2.3.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^22.4.3","ramda":"^0.25.0","react":"16.10.1","enzyme":"^3.10.0","eslint":"^4.19.1","rimraf":"^2.6.2","shelljs":"^0.8.1","webpack":"^4.6.0","babel-cli":"^6.26.0","react-dom":"^16.10.1","babel-core":"^6.26.3","babel-jest":"^22.4.3","prop-types":"^15.6.1","react-redux":"^7.1.1","babel-eslint":"^8.2.3","babel-register":"^6.26.0","babel-preset-env":"^1.6.1","redux-mock-store":"^1.5.1","babel-preset-react":"^6.24.1","eslint-plugin-react":"^7.7.0","react-test-renderer":"^16.3.2","@types/node-polyglot":"^0.4.31","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.11.0","eslint-plugin-jsx-a11y":"^6.0.3","enzyme-adapter-react-16":"^1.14.0","babel-plugin-transform-es2015-modules-umd":"^6.24.1","babel-plugin-transform-object-rest-spread":"^6.26.0"},"peerDependencies":{"react":">= 16.8.0","prop-types":"^15.6.1","react-redux":">= 7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/redux-polyglot_0.8.2_1614778291093_0.4492837070973068","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"0.9.0-beta":{"name":"@cabify/redux-polyglot","version":"0.9.0-beta","keywords":["polyglot","redux","react","i18n","reselect","component enhancer","translation"],"license":"MIT","_id":"@cabify/redux-polyglot@0.9.0-beta","maintainers":[{"name":"cabify-dev","email":"npm@cabify.com"}],"homepage":"https://github.com/Tiqa/redux-polyglot","bugs":{"url":"https://github.com/Tiqa/redux-polyglot/issues"},"dist":{"shasum":"b90f472c4609a0228c0fdfc41abfef2915a518b5","tarball":"https://registry.npmjs.org/@cabify/redux-polyglot/-/redux-polyglot-0.9.0-beta.tgz","fileCount":16,"integrity":"sha512-36xzZ8ZgP6F6mS8GVMaswvkIpRv0F3vn4pghABFh+dyBfYzg3ofMOgMLXv2S3U2zb90nvIO1yjxJb5kUP2nU4g==","signatures":[{"sig":"MEUCIG3o4glXhxp5mstN6/oanwHmkcYD6pSZ77FCKs8fnNCkAiEAtu8umWreJ54cUsZqi31dfF2oIsYMhY+2KZQyTuJXbKM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":30518},"jest":{"roots":["src"],"testURL":"http://localhost","moduleFileExtensions":["js","jsx"],"coveragePathIgnorePatterns":["src/private/test/"],"setupTestFrameworkScriptFile":"./src/private/test/boot.js"},"main":"./dist/index.js","types":"./dist/types.d.ts","readme":"# redux-polyglot\n\n[ ![Codeship Status for Tiqa/redux-polyglot](https://app.codeship.com/projects/21623df0-8959-0134-75f2-0e35097499a9/status?branch=master)](https://app.codeship.com/projects/184177)\n\nToolset (actions, reducer, middleware, enhancer, selectors) to help use Polyglot with Redux.\n\n## Installation\n```\n    npm install --save redux-polyglot\n```\n## Setup\n\nFirst of all, you need the polyglot reducer in your rootReducer :\n```javascript\nimport { createStore, combineReducers } from 'redux';\nimport { polyglotReducer } from 'redux-polyglot';\n\nconst rootReducer = combineReducers({\n    ...yourReducers,\n    polyglot: polyglotReducer,\n});\nconst store = createStore(rootReducer, {});\n\n```\n## Usage\n\n### Set the language\n#### without middleware\nYou can use redux-polyglot without his middleware, for this you need the `setLanguage()` action creator :\n\n- ```setLanguage :: (String, Object) -> Action```\n\nExample:\n```javascript\nimport { setLanguage } from 'redux-polyglot';\n\nstore.dispatch(setLanguage('en', { yolo: 'yolo' }));\n```\nsecond parameter should be `polyglot phrases` (see [polyglot documentation](http://airbnb.io/polyglot.js/))\n\nnote: if language phrases already exists, this will overwrite the corresponding object state.\n\n#### with middleware\nThe `createPolyglotMiddleware()` function allow you to automatically update language and phrases by listening to specific action(s).\n\nThe middleware catches specific action(s), and find the locale in the payload, and then [asynchronously] load the `polyglot phrases` (with Promise).\n\nIt takes 3 parameters and return a middleware :\n- 1 - `actionToCatch :: String | Array<String>`\n    - the type(s) of the action to catch\n- 2 - `getLocale :: Object -> String`\n    - a function that take the catched action as parameter and return new language.\n- 3 - `getPhrases :: String -> Promise Object`\n    - a function that take the language (as provided by `getLocale`) and return a Promise of Object ( Object should be `polyglot phrases` )\n\nthe middleware will catch `actionToCatch`; note: when a matching action is dispatched, it will return this promise called so you can await on it (pretty useful on SSR)\n\n```javascript\nimport { createStore, combineReducers, applyMiddleware } from 'redux';\n\nconst polyglotMiddleware = createPolyglotMiddleware(\n    'ACTION_TO_CATCH',\n    action => action.payload.locale,\n    locale => new Promise(resolve => {\n        // perform async here\n        resolve({\n            hello: 'bonjour',\n        });\n    }),\n)\n\nconst store = createStore(rootReducer, {}, applyMiddleware(polyglotMiddleware));\n```\n\nyou can catch more than one action passing an array of action types:\n```javascript\nconst polyglotMiddleware = createPolyglotMiddleware(\n    ['FIRST_ACTION_TO_CATCH', 'SECOND_ACTION_TO_CATCH'],\n    getLocale,\n    getPhrases,\n)\n```\n\nnote: if language has not changed, nothing happens.\n\n### Translation\n#### with getP() selector\nYou can use the `getP(state)` selector.\n\nIt returns an object with 4 functions inside :\n- t: String -> String : translation (the original polyglot `t` function)\n- tc: String -> String : translation capitalized\n- tt: String -> String : translation titleized\n- tu: String -> String : translation upper-cased\n- tm: (String -> String) -> String -> String :  translation using a custom morphism\n\n(see [polyglot documentation](http://airbnb.io/polyglot.js/))\n\nthere is an optional parameter to getP().\nthis is allow you to automatically 'aim' a scope in your phrases object using `polyglotScope` property.\n\nfor example :\n\n```js\nstore.dispatch(setLanguage('en', {\n    some: { nested: { data: { hello: 'hello' } } }\n}));\nconst p = getP(store.getState(), { polyglotScope: 'some.nested.data' });\nconsole.log(p.tc('hello')) // => will return 'Hello'\n```\n\n#### Getting current locale\n`getLocale(state)` selector returns current language.\n\n#### If you use React\n\nYou can use `connect()` from `react-redux`, and the getP() selector, to get the `p` prop in your component.\n\nProptype:\n````javascript\np: PropTypes.shape({\n    t: PropTypes.func.isRequired,\n    tc: PropTypes.func.isRequired,\n    tu: PropTypes.func.isRequired,\n    tm: PropTypes.func.isRequired,\n}),\n````\n\n##### translate() enhancer\n`props.p` can be also be provided easily to a component with the translate enhancer :\n```javascript\nimport translate from 'redux-polyglot/translate';\nconst DummyComponentWithPProps = translate(DummyComponent);\n```\n\nyou can select a `polyglotScope` with `translate('scope', Component)`\n```js\n// all this lines return an enhanced Dummy component\ntranslate(Dummy);\ntranslate('catalog', Dummy); // with polyglotScope\ntranslate()(Dummy); // curried\ntranslate('catalog')(Dummy); // curried with polyglotScope.\ntranslate({ polyglotScope : 'some.nested.data', ownPhrases: 'some.nested.data.hello': 'Hi !', ... })(Dummy); // curried with object configuration.\n```\n\n##### get locale in a component\nYou can use the `getLocale()` selector inside a [mapStateToProps](https://github.com/reactjs/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options) from react-redux.\n\nProptype: ````locale: PropTypes.string,````\n\n### Overwrite phrases\nIn some case, you should be able to replace some default phrases by others phrases.\n\nFor doing this, you have to define an object which contains your overwrited phrases.\nThis object is composed of : ``` { 'some.nested.data': 'phrase', ... }``` where `key` is the target path you want to replace and `value` ... the new value.\n\n##### with _getP()_ selector\nSimply add `ownPhrases` property and set the new configuration like above to overwrite  :\n```js\nstore.dispatch(setLanguage('en', {\n    some: { nested: { data: { hello: 'hello' } } }\n}));\nconst p = getP(store.getState(), {\n    polyglotScope: 'some.nested.data',\n    ownPhrases: { 'some.nested.data.hello': 'Hi !' }\n});\nconsole.log(p.tc('hello')) // => will return 'Hi !'\n```\n##### with _translate()_ enhancer\nInstead passing only _string_ as parameter : `translate('catalog', Dummy)`, pass a plain _object_ which contains `polyglotScope` and `ownPhrases` properties :\n```js\ntranslate({\n    polyglotScope : 'some.nested.data',\n    ownPhrases: { 'some.nested.data.catalog': 'Cars' }\n}, Dummy);\nconsole.log(p.tc('catalog')) // => will return 'Cars'\n```\n\n### Use polyglot options\nif you want to use `onMissingKey`, `allowMissing` or `warn` [polyglot](http://airbnb.io/polyglot.js/) options, you can use the `createGetP` factory selector to create a custom `getP`.\n\nusage :\n```js\nimport { createGetP } from 'redux-polyglot';\n\nconst options = {\n  allowMissing: true,\n}\n\nexport const getP = createGetP(options);\n```\n\nPlease note you cannot use translate hoc with a custom `getP` selector.\n\n## Team\n\nThese folks keep the project moving and are resources for help:\n\n* Jérémy Vincent ([@jvincent42](https://github.com/jvincent42)) - developer\n* Jalil Arfaoui ([@JalilArfaoui](https://github.com/JalilArfaoui)) - developer\n* Guillaume ARM ([@guillaumearm](https://github.com/guillaumearm/)) - developer\n","gitHead":"e9f1a436a4e47df0b13192e967e2f4030913fdff","scripts":{"tw":"npm run test:watch","lint":"eslint --max-warnings 0 src","test":"jest --coverage","build":"babel src --out-dir dist --ignore '*.spec.js'","clean":"rimraf ./dist","publish":"npm publish --access public --tag beta","test:all":"npm run -s prepublishOnly","test:watch":"jest --watch --coverage","postpublish":"echo --- PUBLISHED ---","prepublishOnly":"node scripts/prepublish.js"},"_npmUser":{"name":"cabify-dev","email":"npm@cabify.com"},"repository":{"url":"git+https://github.com/Tiqa/redux-polyglot.git","type":"git"},"_npmVersion":"6.14.11","description":"Tool for using Polyglot.js with Redux","directories":{},"_nodeVersion":"14.15.5","dependencies":{"redux":"^4.0.0","reselect":"^4.0.0","lodash.curry":"^4.1.1","lodash.assign":"^4.2.0","node-polyglot":"^2.3.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^22.4.3","ramda":"^0.25.0","react":"16.10.1","enzyme":"^3.10.0","eslint":"^4.19.1","rimraf":"^2.6.2","shelljs":"^0.8.1","webpack":"^4.6.0","babel-cli":"^6.26.0","react-dom":"^16.10.1","babel-core":"^6.26.3","babel-jest":"^22.4.3","prop-types":"^15.7.2","react-redux":"^7.1.1","babel-eslint":"^8.2.3","babel-register":"^6.26.0","babel-preset-env":"^1.6.1","redux-mock-store":"^1.5.1","babel-preset-react":"^6.24.1","eslint-plugin-react":"^7.7.0","react-test-renderer":"^16.3.2","@types/node-polyglot":"^0.4.31","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.11.0","eslint-plugin-jsx-a11y":"^6.0.3","enzyme-adapter-react-16":"^1.14.0","babel-plugin-transform-es2015-modules-umd":"^6.24.1","babel-plugin-transform-object-rest-spread":"^6.26.0"},"peerDependencies":{"react":">= 16.8.0","prop-types":"^15.7.2","react-redux":">= 7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/redux-polyglot_0.9.0-beta_1632388427230_0.8698955260886412","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"0.9.0":{"name":"@cabify/redux-polyglot","version":"0.9.0","keywords":["polyglot","redux","react","i18n","reselect","component enhancer","translation"],"license":"MIT","_id":"@cabify/redux-polyglot@0.9.0","maintainers":[{"name":"cabify-dev","email":"npm@cabify.com"}],"homepage":"https://github.com/Tiqa/redux-polyglot","bugs":{"url":"https://github.com/Tiqa/redux-polyglot/issues"},"dist":{"shasum":"e7a7bd9661aa1559d8afa5c3924f17082f647236","tarball":"https://registry.npmjs.org/@cabify/redux-polyglot/-/redux-polyglot-0.9.0.tgz","fileCount":16,"integrity":"sha512-ZMlDDkP74/9cO8TDDK0B8g6bk6sEBy/CtOC1aNH6N9rWH1JETjrzluSxJrMAb2VZnQqzOsvIdrBkmmtNaAFdEg==","signatures":[{"sig":"MEUCIER68A8aISQWCGao4ekIwdSQnhp38VAO9DpfQk6po8UCAiEAk5YtDrUBhZTPUM5TT3t1bE2jIzGF6VgDBiev03ZHJis=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":30502,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhzasECRA9TVsSAnZWagAAvXsP/jjVl2BePW6HFv9wcKgY\nnmP9XuwBe1P+vwnx+VsJKVps1h2veSlrS/3EkhV9gGncrk7Hvf7g8LR83Git\nk9vaNDRx1F3Pb18e40fRbhBrfCLAE7upV376aAuO5u1iAbhCaz1jcJkxhFIy\ngP0lSyYGBONa61AiBPwiOhSqgaml1CisnvuHlDiVlSLIMvYi4E9DbnJfmL12\nkSUbc5Vrbpt9XN6tV1guN90jyjd3gF31+bDKiusYNkABbfMqIjreQNETMiUz\n47UWwHV4id6ufuPwuJjBfndZbcHKtqlq96MnMuwGIcappNuxSIKZhsLeunPX\niJN80IFUmN3UGt9qKOEJ9R8qwPu5fsw5SNa4gk6Es0BK7HNQMcnHIhDE1ehP\n3eFaDG7YwPECJm3uPdcO5H99e8cHU5VSvLnDsNdOO1GbuUMGEz0mNxxsoZmz\nGpPUqGO50UP4cD0Spuo/46oCVq9BnXegDIcq/0PuIrFLQEL5cI+7bFZmyt+x\n6k2iLglCuqV6bwGnJk6MKHWvmo0q8izedCk8kiURZ/7+8Y9nf9v7PxWiuLxi\ncQBrOd4ZL5lX9AAOIB82+QmHrD99Sdylfx6Q+zfNqF/TVEkpp402CKdeKZ5z\n4oTRx0GKzKY3h77sYFottcgmyk5WEmY4P7jINIQVtOz8SPUFixGsAe/tw5TK\n0UgP\r\n=2cj1\r\n-----END PGP SIGNATURE-----\r\n"},"jest":{"roots":["src"],"testURL":"http://localhost","moduleFileExtensions":["js","jsx"],"coveragePathIgnorePatterns":["src/private/test/"],"setupTestFrameworkScriptFile":"./src/private/test/boot.js"},"main":"./dist/index.js","types":"./dist/types.d.ts","gitHead":"667f47db88b400003878a3839aa1b3ed7bd2e9c9","scripts":{"tw":"npm run test:watch","lint":"eslint --max-warnings 0 src","test":"jest --coverage","build":"babel src --out-dir dist --ignore '*.spec.js'","clean":"rimraf ./dist","publish":"npm publish --access public","test:all":"npm run -s prepublishOnly","test:watch":"jest --watch --coverage","postpublish":"echo --- PUBLISHED ---","prepublishOnly":"node scripts/prepublish.js"},"_npmUser":{"name":"cabify-dev","email":"npm@cabify.com"},"repository":{"url":"git+https://github.com/Tiqa/redux-polyglot.git","type":"git"},"_npmVersion":"6.14.11","description":"Tool for using Polyglot.js with Redux","directories":{},"_nodeVersion":"14.15.5","dependencies":{"redux":"^4.0.0","reselect":"^4.0.0","lodash.curry":"^4.1.1","lodash.assign":"^4.2.0","node-polyglot":"^2.3.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^22.4.3","ramda":"^0.25.0","react":"16.10.1","enzyme":"^3.10.0","eslint":"^4.19.1","rimraf":"^2.6.2","shelljs":"^0.8.1","webpack":"^4.6.0","babel-cli":"^6.26.0","react-dom":"^16.10.1","babel-core":"^6.26.3","babel-jest":"^22.4.3","prop-types":"^15.7.2","react-redux":"^7.1.1","babel-eslint":"^8.2.3","babel-register":"^6.26.0","babel-preset-env":"^1.6.1","redux-mock-store":"^1.5.1","babel-preset-react":"^6.24.1","eslint-plugin-react":"^7.7.0","react-test-renderer":"^16.3.2","@types/node-polyglot":"^0.4.31","eslint-config-airbnb":"^16.1.0","eslint-plugin-import":"^2.11.0","eslint-plugin-jsx-a11y":"^6.0.3","enzyme-adapter-react-16":"^1.14.0","babel-plugin-transform-es2015-modules-umd":"^6.24.1","babel-plugin-transform-object-rest-spread":"^6.26.0"},"peerDependencies":{"react":">= 16.8.0","prop-types":"^15.7.2","react-redux":">= 7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/redux-polyglot_0.9.0_1632411645215_0.19601198184551105","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."}},"time":{"created":"2021-03-03T13:08:33.477Z","modified":"2025-07-08T11:42:12.355Z","0.8.1":"2021-03-03T13:08:33.762Z","0.8.2":"2021-03-03T13:31:31.255Z","0.9.0-beta":"2021-09-23T09:13:47.431Z","0.9.0":"2021-09-23T15:40:45.354Z"},"bugs":{"url":"https://github.com/Tiqa/redux-polyglot/issues"},"license":"MIT","homepage":"https://github.com/Tiqa/redux-polyglot","keywords":["polyglot","redux","react","i18n","reselect","component enhancer","translation"],"repository":{"url":"git+https://github.com/Tiqa/redux-polyglot.git","type":"git"},"description":"Tool for using Polyglot.js with Redux","maintainers":[{"name":"cabify-dev","email":"npm@cabify.com"}],"readme":"# redux-polyglot\n\n[ ![Codeship Status for Tiqa/redux-polyglot](https://app.codeship.com/projects/21623df0-8959-0134-75f2-0e35097499a9/status?branch=master)](https://app.codeship.com/projects/184177)\n\nToolset (actions, reducer, middleware, enhancer, selectors) to help use Polyglot with Redux.\n\n## Installation\n```\n    npm install --save redux-polyglot\n```\n## Setup\n\nFirst of all, you need the polyglot reducer in your rootReducer :\n```javascript\nimport { createStore, combineReducers } from 'redux';\nimport { polyglotReducer } from 'redux-polyglot';\n\nconst rootReducer = combineReducers({\n    ...yourReducers,\n    polyglot: polyglotReducer,\n});\nconst store = createStore(rootReducer, {});\n\n```\n## Usage\n\n### Set the language\n#### without middleware\nYou can use redux-polyglot without his middleware, for this you need the `setLanguage()` action creator :\n\n- ```setLanguage :: (String, Object) -> Action```\n\nExample:\n```javascript\nimport { setLanguage } from 'redux-polyglot';\n\nstore.dispatch(setLanguage('en', { yolo: 'yolo' }));\n```\nsecond parameter should be `polyglot phrases` (see [polyglot documentation](http://airbnb.io/polyglot.js/))\n\nnote: if language phrases already exists, this will overwrite the corresponding object state.\n\n#### with middleware\nThe `createPolyglotMiddleware()` function allow you to automatically update language and phrases by listening to specific action(s).\n\nThe middleware catches specific action(s), and find the locale in the payload, and then [asynchronously] load the `polyglot phrases` (with Promise).\n\nIt takes 3 parameters and return a middleware :\n- 1 - `actionToCatch :: String | Array<String>`\n    - the type(s) of the action to catch\n- 2 - `getLocale :: Object -> String`\n    - a function that take the catched action as parameter and return new language.\n- 3 - `getPhrases :: String -> Promise Object`\n    - a function that take the language (as provided by `getLocale`) and return a Promise of Object ( Object should be `polyglot phrases` )\n\nthe middleware will catch `actionToCatch`; note: when a matching action is dispatched, it will return this promise called so you can await on it (pretty useful on SSR)\n\n```javascript\nimport { createStore, combineReducers, applyMiddleware } from 'redux';\n\nconst polyglotMiddleware = createPolyglotMiddleware(\n    'ACTION_TO_CATCH',\n    action => action.payload.locale,\n    locale => new Promise(resolve => {\n        // perform async here\n        resolve({\n            hello: 'bonjour',\n        });\n    }),\n)\n\nconst store = createStore(rootReducer, {}, applyMiddleware(polyglotMiddleware));\n```\n\nyou can catch more than one action passing an array of action types:\n```javascript\nconst polyglotMiddleware = createPolyglotMiddleware(\n    ['FIRST_ACTION_TO_CATCH', 'SECOND_ACTION_TO_CATCH'],\n    getLocale,\n    getPhrases,\n)\n```\n\nnote: if language has not changed, nothing happens.\n\n### Translation\n#### with getP() selector\nYou can use the `getP(state)` selector.\n\nIt returns an object with 4 functions inside :\n- t: String -> String : translation (the original polyglot `t` function)\n- tc: String -> String : translation capitalized\n- tt: String -> String : translation titleized\n- tu: String -> String : translation upper-cased\n- tm: (String -> String) -> String -> String :  translation using a custom morphism\n\n(see [polyglot documentation](http://airbnb.io/polyglot.js/))\n\nthere is an optional parameter to getP().\nthis is allow you to automatically 'aim' a scope in your phrases object using `polyglotScope` property.\n\nfor example :\n\n```js\nstore.dispatch(setLanguage('en', {\n    some: { nested: { data: { hello: 'hello' } } }\n}));\nconst p = getP(store.getState(), { polyglotScope: 'some.nested.data' });\nconsole.log(p.tc('hello')) // => will return 'Hello'\n```\n\n#### Getting current locale\n`getLocale(state)` selector returns current language.\n\n#### If you use React\n\nYou can use `connect()` from `react-redux`, and the getP() selector, to get the `p` prop in your component.\n\nProptype:\n````javascript\np: PropTypes.shape({\n    t: PropTypes.func.isRequired,\n    tc: PropTypes.func.isRequired,\n    tu: PropTypes.func.isRequired,\n    tm: PropTypes.func.isRequired,\n}),\n````\n\n##### translate() enhancer\n`props.p` can be also be provided easily to a component with the translate enhancer :\n```javascript\nimport translate from 'redux-polyglot/translate';\nconst DummyComponentWithPProps = translate(DummyComponent);\n```\n\nyou can select a `polyglotScope` with `translate('scope', Component)`\n```js\n// all this lines return an enhanced Dummy component\ntranslate(Dummy);\ntranslate('catalog', Dummy); // with polyglotScope\ntranslate()(Dummy); // curried\ntranslate('catalog')(Dummy); // curried with polyglotScope.\ntranslate({ polyglotScope : 'some.nested.data', ownPhrases: 'some.nested.data.hello': 'Hi !', ... })(Dummy); // curried with object configuration.\n```\n\n##### get locale in a component\nYou can use the `getLocale()` selector inside a [mapStateToProps](https://github.com/reactjs/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options) from react-redux.\n\nProptype: ````locale: PropTypes.string,````\n\n### Overwrite phrases\nIn some case, you should be able to replace some default phrases by others phrases.\n\nFor doing this, you have to define an object which contains your overwrited phrases.\nThis object is composed of : ``` { 'some.nested.data': 'phrase', ... }``` where `key` is the target path you want to replace and `value` ... the new value.\n\n##### with _getP()_ selector\nSimply add `ownPhrases` property and set the new configuration like above to overwrite  :\n```js\nstore.dispatch(setLanguage('en', {\n    some: { nested: { data: { hello: 'hello' } } }\n}));\nconst p = getP(store.getState(), {\n    polyglotScope: 'some.nested.data',\n    ownPhrases: { 'some.nested.data.hello': 'Hi !' }\n});\nconsole.log(p.tc('hello')) // => will return 'Hi !'\n```\n##### with _translate()_ enhancer\nInstead passing only _string_ as parameter : `translate('catalog', Dummy)`, pass a plain _object_ which contains `polyglotScope` and `ownPhrases` properties :\n```js\ntranslate({\n    polyglotScope : 'some.nested.data',\n    ownPhrases: { 'some.nested.data.catalog': 'Cars' }\n}, Dummy);\nconsole.log(p.tc('catalog')) // => will return 'Cars'\n```\n\n### Use polyglot options\nif you want to use `onMissingKey`, `allowMissing` or `warn` [polyglot](http://airbnb.io/polyglot.js/) options, you can use the `createGetP` factory selector to create a custom `getP`.\n\nusage :\n```js\nimport { createGetP } from 'redux-polyglot';\n\nconst options = {\n  allowMissing: true,\n}\n\nexport const getP = createGetP(options);\n```\n\nPlease note you cannot use translate hoc with a custom `getP` selector.\n\n## Team\n\nThese folks keep the project moving and are resources for help:\n\n* Jérémy Vincent ([@jvincent42](https://github.com/jvincent42)) - developer\n* Jalil Arfaoui ([@JalilArfaoui](https://github.com/JalilArfaoui)) - developer\n* Guillaume ARM ([@guillaumearm](https://github.com/guillaumearm/)) - developer\n","readmeFilename":"README.md"}