{"_id":"@iqoption/affiliate-redux-translations","_rev":"25-e14ea4b5d52c0e554091e1a5e17f1883","time":{"0.0.0":"2019-05-23T13:11:51.897Z","0.1.6":"2019-05-23T13:11:51.897Z","0.1.7":"2019-05-23T13:11:51.897Z","0.1.8":"2019-05-23T13:11:51.897Z","0.1.9":"2019-05-23T13:11:51.897Z","created":"2019-05-27T09:25:40.254Z","2.0.1":"2019-05-27T09:25:40.491Z","modified":"2022-04-05T21:07:58.783Z","2.0.2":"2019-05-27T09:49:44.847Z"},"name":"@iqoption/affiliate-redux-translations","dist-tags":{"latest":"2.0.2"},"versions":{"2.0.1":{"name":"@iqoption/affiliate-redux-translations","version":"2.0.1","description":"translations utils for react-redux apps","main":"./build/index.js","types":"./build/index.d.ts","scripts":{"test":"jest","test:watch":"jest --watch","commit":"git-cz","prettify":"prettier --single-quote --trailing-comma es5 --parser typescript --write \"@(src|__tests__)/**/*.ts?(x)\"","build":"rm -rf ./build && tsc -p ./tsconfig.json","codecov":"cat ./coverage/lcov.info | codecov","_semantic-release":"semantic-release"},"repository":{"type":"git","url":"https://gitlab.mobbtech.com/affiliate/affiliate-redux-translations.git"},"keywords":["react","redux","translations"],"author":{"name":"Oleg Repin","email":"iamolegga@gmail.com","url":"http://github.com/iamolegga"},"license":"MIT","bugs":{"url":"https://gitlab.mobbtech.com/affiliate/affiliate-redux-translations/issues"},"homepage":"https://gitlab.mobbtech.com/affiliate/affiliate-redux-translations#readme","devDependencies":{"@types/enzyme":"^3.9.1","@types/enzyme-adapter-react-16":"^1.0.5","@types/hoist-non-react-statics":"3.3.1","@types/jest":"^22.2.3","@types/node":"^9.6.47","@types/react":"^16.8.13","@types/react-dom":"^16.8.4","@types/react-redux":"^5.0.21","@types/redux":"^3.6.31","codecov.io":"^0.1.6","commitizen":"^2.10.1","cz-conventional-changelog":"^2.1.0","enzyme":"^3.9.0","enzyme-adapter-react-16":"^1.12.1","ghooks":"^2.0.4","jest":"^22.4.4","prettier":"^1.17.0","react":"^16.8.6","react-dom":"^16.8.6","react-redux":"^5.1.1","react-test-renderer":"^16.8.6","redux":"^3.7.2","semantic-release":"^12.4.1","ts-jest":"^22.4.6","typescript":"3.4.4"},"peerDependencies":{"react":">=0.14.0","react-redux":">=4.0.0","redux":">=3.0.0"},"jest":{"testURL":"http://localhost","collectCoverage":true,"collectCoverageFrom":["**/src/**/*.ts?(x)","!**/node_modules/**"],"coverageDirectory":"coverage","coverageReporters":["json","lcov","html"],"coverageThreshold":{"global":{"branches":67,"functions":85,"lines":86,"statements":75}},"transform":{"^.+\\.tsx?$":"<rootDir>/node_modules/ts-jest/preprocessor.js"},"testRegex":"(/__tests__/.*|\\.(test|spec|snapshot))\\.(ts|tsx|js)$","moduleFileExtensions":["ts","tsx","js","json"]},"config":{"commitizen":{"path":"cz-conventional-changelog"},"ghooks":{"pre-commit":"npm run prettify && npm run build && npm t"}},"dependencies":{"hoist-non-react-statics":"3.3.0"},"gitHead":"f3ce7842a344d788d754572e51648a3b6ba92f47","_id":"@iqoption/affiliate-redux-translations@2.0.1","_npmVersion":"5.6.0","_nodeVersion":"10.1.0","_npmUser":{"name":"victorfomenko","email":"victorfomenko@me.com"},"dist":{"integrity":"sha512-BhSWXxhycoQRenehN8eA770z6arwyiCeF3nga/wS42eLvgZYOhV0Q79Qs+YGcpTTUPZF+KMgGZXCY0HtU0oElw==","shasum":"87381d7ba21d26c3e6d90e4e350de58417d3c25c","tarball":"https://registry.npmjs.org/@iqoption/affiliate-redux-translations/-/affiliate-redux-translations-2.0.1.tgz","fileCount":9,"unpackedSize":41739,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc660UCRA9TVsSAnZWagAAQPYP/jpgRcT78S9L0Pom97PF\n8JNisRAsBMzh7y2ZXzh2yB78QtLHBgqepg3sTVEUOkg5zW97HsyGc4w6k/1s\nzAQeu/KKXmyUmKSg0Y+tDWbzr1RxCYXhoIeaTC03t1pay2UkYmFM2jluUr5G\n+yriQ2JWTnkghzoGuPK9nwSEtvevcOKcemceY98rf1Hit/1U0Vf4HDnvkWth\nDWimp0eIOJah+SWarFMbafJdgOgvyyxHHl7FLVdUzXTpZLhyOg+H1rqcx9bv\n0sBTAhnDY+z9GAK3C4MMg1lzYdCNvy5CtljRBPLAMDEURmxiKiAXfHT75sMc\nuqNePY862A20ers+pMFuq75XpCaTTBfpF2aZVJId98WDYHJtORdYPxE111fs\n8S2fjsszytfdG+6QBGxdTUJwvwh3PFI6E6Ccm4fpIbZPqNtAnPWhNJT1lXXM\nn+fbuHPhAPwCjqQnzM4HqgFjQmZssmi4qumihcrVl6rpxyuvsWmSSAZ7gqKR\nyNTui7+ybzgj0OdLh4qDRVLkcCkDR1IJsKTjHohoUoo8V3l/Z1Uac+wqx4ej\nsRD6+knVVWnczJWcEYjW+WLTU5yUCqOcf3V7p6mCt46HA1ZpddKcTpViUsCg\nWrR8cYo2dY2Eb8kywhBInw1gYfMLsFs0FSQCviw5UsbmvESrDMijq17EnhqD\nCv9k\r\n=eSpg\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICsTaE4IscNaPHP1iU5y37JRPWuDkY86/fAaFEP8W2YpAiAF1um7pEgU4cBgdjhNFW06IVGx3nsb3MeRPHI1Fd8Z1Q=="}]},"maintainers":[{"name":"victorfomenko","email":"victorfomenko@me.com"},{"name":"sashafmp","email":"valuevich@yandex.ru"},{"name":"iamolegga","email":"iamolegga@gmail.com"},{"name":"pahomov","email":"pahomov@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/affiliate-redux-translations_2.0.1_1558949140391_0.1213287823495881"},"_hasShrinkwrap":false},"2.0.2":{"name":"@iqoption/affiliate-redux-translations","version":"2.0.2","description":"translations utils for react-redux apps","main":"./build/index.js","types":"./build/index.d.ts","scripts":{"test":"jest","test:watch":"jest --watch","commit":"git-cz","prettify":"prettier --single-quote --trailing-comma es5 --parser typescript --write \"@(src|__tests__)/**/*.ts?(x)\"","build":"rm -rf ./build && tsc -p ./tsconfig.json","codecov":"cat ./coverage/lcov.info | codecov","_semantic-release":"semantic-release"},"repository":{"type":"git","url":"https://gitlab.mobbtech.com/affiliate/affiliate-redux-translations.git"},"keywords":["react","redux","translations"],"author":{"name":"Oleg Repin","email":"iamolegga@gmail.com","url":"http://github.com/iamolegga"},"license":"MIT","bugs":{"url":"https://gitlab.mobbtech.com/affiliate/affiliate-redux-translations/issues"},"homepage":"https://gitlab.mobbtech.com/affiliate/affiliate-redux-translations#readme","devDependencies":{"@types/enzyme":"^3.9.1","@types/enzyme-adapter-react-16":"^1.0.5","@types/hoist-non-react-statics":"3.3.1","@types/jest":"^22.2.3","@types/node":"^9.6.47","@types/react":"^16.8.13","@types/react-dom":"^16.8.4","@types/react-redux":"^5.0.21","@types/redux":"^3.6.31","codecov.io":"^0.1.6","commitizen":"^2.10.1","cz-conventional-changelog":"^2.1.0","enzyme":"^3.9.0","enzyme-adapter-react-16":"^1.12.1","ghooks":"^2.0.4","jest":"^22.4.4","prettier":"^1.17.0","react":"^16.8.6","react-dom":"^16.8.6","react-redux":"^5.1.1","react-test-renderer":"^16.8.6","redux":"^3.7.2","semantic-release":"^12.4.1","ts-jest":"^22.4.6","typescript":"3.4.4"},"peerDependencies":{"react":">=0.14.0","react-redux":">=4.0.0","redux":">=3.0.0"},"jest":{"testURL":"http://localhost","collectCoverage":true,"collectCoverageFrom":["**/src/**/*.ts?(x)","!**/node_modules/**"],"coverageDirectory":"coverage","coverageReporters":["json","lcov","html"],"coverageThreshold":{"global":{"branches":67,"functions":85,"lines":86,"statements":75}},"transform":{"^.+\\.tsx?$":"<rootDir>/node_modules/ts-jest/preprocessor.js"},"testRegex":"(/__tests__/.*|\\.(test|spec|snapshot))\\.(ts|tsx|js)$","moduleFileExtensions":["ts","tsx","js","json"]},"config":{"commitizen":{"path":"cz-conventional-changelog"},"ghooks":{"pre-commit":"npm run prettify && npm run build && npm t"}},"dependencies":{"hoist-non-react-statics":"3.3.0"},"gitHead":"f3ce7842a344d788d754572e51648a3b6ba92f47","_id":"@iqoption/affiliate-redux-translations@2.0.2","_npmVersion":"5.6.0","_nodeVersion":"10.1.0","_npmUser":{"name":"victorfomenko","email":"victorfomenko@me.com"},"dist":{"integrity":"sha512-ahAETiyIWPWUpR4q6UQ5O04IQTqZZxZvZg+c/BhwmFYb2jLMqBj5oBYnD5IIr9eea/z51r8qhZNi0fY5AFp76w==","shasum":"bcd3d58ed07b8126b425e1f6571e69c37ca4e4ab","tarball":"https://registry.npmjs.org/@iqoption/affiliate-redux-translations/-/affiliate-redux-translations-2.0.2.tgz","fileCount":12,"unpackedSize":62258,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc67K5CRA9TVsSAnZWagAAx0YP/3Cj3VovhClm2nrV5bEH\nw9A35OHrGVPntIT8C4/ArJWv3eUyGOWQ3F79qMjNAtblrUyJQc9lSP3zT0JA\nW+ID8Gj+CS8O/MUChhrrxul4/xH0ujUiBvnD8raCLzK4yiuKUT3lx3MtizeX\nO+LqPfdM3vN7TLPh7/JzHCrQ/KTrlYcFo2BVjcX221oNAl68+UUPHvGealoQ\nEr7mSJ3Jh0SjAOpqytBoc1pLRwDtJFnJ05w6+QFc+nLSYNTH/z+spF2aa88z\nuuOR0JFrBDGZ0NGk3nw/AvL9wL51UzC4ZIDQuQDDPAxTiwRk4F3NnlalWvGy\nD8vPaMZXgqle8bAaKNzN7BMAGn6JtTAQ5OJeEB8ucJKoZ8UbHSypKZBLga80\ntVHO/7F5TsYKEG99qJwCjZvn39m6NnmAicGZO6vr5o+tjquJhxIxOK0ZCaKx\np6inY9lZ/jnoLKfM6g8uO2nXgw2iKKMnCUmEPrKneYhdLFtP1smd08aL9s6a\np02H0IH84t/L2iUpvYkhOislp3fXTjjEwzuyctHDGBOyoi3tfCt+E8+M6U/M\nPhbovPDD6NOaJAqk+kbc1bubttCd0/LOGXziumA7udNA17UJCT9RyioZMCNz\nC7QBG5Tv0KTkbv4JHyFURBR/4jUnP0GbDZ4x7pcsVDFSRFnawwMtkTh9tE1z\nAUH0\r\n=K7lG\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHYJNIqU6cGaBGPaWa+5yuBqGpK6zb5Z7qXgW/2Kv1pZAiEAkajwm0lEk9GM4j+ICeOh+C10p7QCH7kOXAnjixAKxZw="}]},"maintainers":[{"name":"iamolegga","email":"iamolegga@gmail.com"},{"name":"pahomov","email":"pahomov@gmail.com"},{"name":"sashafmp","email":"valuevich@yandex.ru"},{"name":"victorfomenko","email":"victorfomenko@me.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/affiliate-redux-translations_2.0.2_1558950584744_0.11801678041268149"},"_hasShrinkwrap":false}},"maintainers":[{"name":"iamolegga","email":"iamolegga@gmail.com"},{"name":"pahomov","email":"pahomov@gmail.com"},{"name":"sashafmp","email":"valuevich@yandex.ru"},{"name":"victorfomenko","email":"victorfomenko@me.com"}],"description":"translations utils for react-redux apps","homepage":"https://gitlab.mobbtech.com/affiliate/affiliate-redux-translations#readme","keywords":["react","redux","translations"],"repository":{"type":"git","url":"https://gitlab.mobbtech.com/affiliate/affiliate-redux-translations.git"},"author":{"name":"Oleg Repin","email":"iamolegga@gmail.com","url":"http://github.com/iamolegga"},"bugs":{"url":"https://gitlab.mobbtech.com/affiliate/affiliate-redux-translations/issues"},"license":"MIT","readme":"# redux-translations\n\nTranslations utils for react-redux apps\n\n[![Greenkeeper badge](https://badges.greenkeeper.io/iamolegga/redux-translations.svg)](https://greenkeeper.io/)\n[![npm](https://img.shields.io/npm/v/redux-translations.svg)](https://www.npmjs.com/package/redux-translations)\n[![npm](https://img.shields.io/npm/dw/redux-translations.svg)](https://www.npmjs.com/package/redux-translations)\n[![Travis](https://img.shields.io/travis/iamolegga/redux-translations.svg)](https://travis-ci.org/iamolegga/redux-translations)\n[![Codecov](https://img.shields.io/codecov/c/github/iamolegga/redux-translations.svg)](https://codecov.io/gh/iamolegga/redux-translations)\n[![license](https://img.shields.io/github/license/iamolegga/redux-translations.svg)](https://github.com/iamolegga/redux-translations)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![Libraries.io for GitHub](https://img.shields.io/librariesio/github/iamolegga/redux-translations.svg)](https://libraries.io/github/iamolegga/redux-translations)\n\n## Install\n\n```sh\nnpm i @iqoption/affiliate-redux-translations\n```\n\n## Usage\n\n### Translations middleware\n\nCreate and config translations middleware and apply it.\n\n```js\nimport { createTranslationsMiddleware } from \"@iqoption/affiliate-redux-translations\";\n\n// Change this function to yours\nconst functionThatReturnsPromiseWithDictionary = language =>\n  Promise.resolve(\n    language === \"en\" ? { hello: \"Hello!\" } : { hello: \"Привет!\" }\n  );\n\nconst translationsMiddleware = createTranslationsMiddleware(\n  functionThatReturnsPromiseWithDictionary\n);\n\nconst store = createStore(rootReducer, applyMiddleware(translationsMiddleware));\n```\n\n### Translations props\n\nWrap component with `withTranslations` function:\n\n```jsx\nimport withTranslations from \"@iqoption/affiliate-redux-translations\";\n\nconst MyComponent = ({ dictionary, currentLang, loadingLang, switchLang }) => (\n  <div>\n    Translated text: {dictionary[\"hello\"]}\n    <br />\n    Current language: {currentLang}\n    <br />\n    Loading language: {loadingLang}\n    <button onClick={() => switchLang(\"en\")}>English</button>\n    <br />\n    <button onClick={() => switchLang(\"ru\")}>Russian</button>\n  </div>\n);\n\nconst MyComponentTranslated = withTranslations(MyComponent);\n```\n\nYou can change language not only in react-component:\n\n```js\nimport { switchLangActionCreator } from \"@iqoption/affiliate-redux-translations\";\nstore.dispatch(switchLangActionCreator(\"en\"));\n```\n\n## API\n\n### `createTranslationsMiddleware(getDictionary, [options], [initialState])`\n\nFunction, that creates redux-middleware for translations. Has next arguments:\n\n1. `getDictionary` (Function) - function with one argument type of `string` - language, that user is switching to, and returns promise with `dictionary` object.\n\n2. `[options]` (Object) - options object with next optional fields:\n\n- `cache` (Boolean) - should cache results of `getDictionary`, and do not call it if dictionary is already loaded. Default `true`.\n- `updateCacheOnSwitch` (Boolean) - when `cache` is `true`, should switch immediately to cached dictionary, but load dictionary in background one more time and replace old with the new one. Default `false`.\n- `startSwitchCallback` (Function) - callback for every language switching start. Run exactly in switch event, without waiting for fetching dictionary. Takes next arguments: `loadingLang` (String) and `store`. Default `undefined`.\n- `endSwitchCallback` (Function) - callback for every language switching end. Run exactly after fetching dictionary. Takes next arguments: `loadedLang` (String), `dictionary` (Object) and `store`. Default `undefined`.\n\n3. `[initialState]` (Object) - initial inner state object with next optional fields:\n\n- `dictionaries` (Object) - hash-table of dictionaries, where key is language name and value is dictionary. Default `{}`.\n- `currentLang` (String) - current language with fetched dictionary. Default `null`.\n- `loadingLang` (String) - language that user is switching to, but not fetched dictionary yet. Default `null`.\n\n### `withTranslations(Component, [copyStaticMethods])`\n\nReact component class wrapper that adds next props to wrapping component class (actually it returns new component class):\n\n1. `currentLang` (String) - language, which dictionary is currently using.\n\n2. `loadingLang` (String) - language, which dictionary is currently loading.\n\n3. `dictionary` (Object) - object, that is returned by `getDictionary`.\n\n4. `switchLang` (Function) - function, that switch language to passed one.\n\nArguments:\n\n1. `Component` (Function) - component that depends on props, listed above.\n\n2. `copyStaticMethods` (Boolean) - whether to copy static methods of Component or not. Default `true`.\n\n### `switchLangActionCreator(language)`\n\nRedux action creator - function with one argument type of `string`, returns flux standard action (FSA), that you can dispatch whereever in your app (for example, when initialising your app).\n\n### `patchState(changes, [updateComponents])`\n\nPatch translations inner state without dispatching redux action. Could be useful for server-side rendering or another cases where `store.dispatch` function is unreachable. Returns Promise, resolved when all components are updated (if updateComponents === true) or immediately. Has next arguments:\n\n1. `changes` (Object) - partial initial inner state object with next optional fields:\n\n- `dictionaries` (Object) - hash-table of dictionaries, where key is language name and value is dictionary.\n- `currentLang` (String) - current language with fetched dictionary.\n- `loadingLang` (String) - language that user is switching to, but not fetched dictionary yet.\n\n2. `updateComponents` (Boolean) - whether to update components or not.\n","readmeFilename":"README.md"}