{"id":15917199,"url":"https://github.com/rmdort/react-redux-multilingual","last_synced_at":"2025-03-24T07:31:57.237Z","repository":{"id":57343289,"uuid":"61524241","full_name":"rmdort/react-redux-multilingual","owner":"rmdort","description":"A simple and slim multi-lingual component for React with Redux without react-intl or react-i18n","archived":false,"fork":false,"pushed_at":"2020-03-28T04:06:27.000Z","size":29,"stargazers_count":42,"open_issues_count":1,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-19T03:13:12.840Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rmdort.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-20T07:05:06.000Z","updated_at":"2025-03-02T13:34:41.000Z","dependencies_parsed_at":"2022-09-12T07:00:22.686Z","dependency_job_id":null,"html_url":"https://github.com/rmdort/react-redux-multilingual","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmdort%2Freact-redux-multilingual","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmdort%2Freact-redux-multilingual/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmdort%2Freact-redux-multilingual/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmdort%2Freact-redux-multilingual/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rmdort","download_url":"https://codeload.github.com/rmdort/react-redux-multilingual/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245227480,"owners_count":20580888,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-06T18:09:34.331Z","updated_at":"2025-03-24T07:31:56.978Z","avatar_url":"https://github.com/rmdort.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Multilingual with redux\n\nA simple and slim (Only 6KB) multi-lingual component for React with Redux without react-intl or react-i18n\n\n## Install\n\n```\nnpm i react-redux-multilingual --save\n```\n\n## Wiring it up\n\n```js\nimport translations from './translations'\nimport { IntlReducer as Intl, IntlProvider } from 'react-redux-multilingual'\nimport { createStore, combineReducers } from 'redux'\nimport { Provider } from 'react-redux'\nimport App from './App'\n\nlet reducers = combineReducers(Object.assign({}, { Intl }))\nlet store = createStore(reducers)\n\nReactDOM.render(\n  \u003cProvider store={store}\u003e\n    \u003cIntlProvider translations={translations} locale='en'\u003e\n      \u003cApp /\u003e\n    \u003c/IntlProvider\u003e\n  \u003c/Provider\u003e\n, document.getElementById('root'))\n```\n\n## Translations format\nThe translations props accepts object in this format\n\n```js\n{\n  en: {\n    locale: 'en-US',\n    messages: {\n      hello: 'how are you {name}'\n    }\n  },\n  zh: {\n    locale: 'zh',\n    messages: {\n      hello: '你好！你好吗 {name}'\n    }\n  }\n}\n```\n\n## Translate using hook\n\n```js\nimport { useTranslate } from 'react-redux-multilingual'\n\nfunction App () {\n  const t = useTranslate()\n\n  return (\n    \u003cdiv\u003e\n      {t('hello', { name: 'Foo Bar'})}\n    \u003c/div\u003e\n  )\n}\n```\n\n## Translate using higher-order component (HOC)\n\n```js\nimport { withTranslate } from 'react-redux-multilingual'\n\nconst App = ({ translate }) = {\n  return (\n    \u003cdiv\u003e\n      {translate('hello', { name: 'John Doe' })}\n    \u003c/div\u003e\n  )\n}\n\nmodule.exports = withTranslate(App)\n```\n\n## Translate using Context\n\n```js\nconst App = (props, context) =\u003e {\n  return (\n    \u003cdiv\u003e\n      {context.translate('hello', { name: 'John Doe' })}\n    \u003c/div\u003e\n  )\n}\n\nApp.contextTypes = {\n  translate: React.propTypes.func\n}\n\nmodule.exports = App\n```\n\n## Setting the initial locale\n\nOption 1: Pass your locale to initial state of your reducer\n```js\nlet store = createStore(reducers, { Intl: { locale: 'zh'}})\n```\n\nOption 2: Dispatch an action to change locale\n```js\nimport { IntlActions } from 'react-redux-multilingual'\nlet store = createStore(reducers)\nstore.dispatch(IntlActions.setLocale('zh'))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmdort%2Freact-redux-multilingual","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frmdort%2Freact-redux-multilingual","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmdort%2Freact-redux-multilingual/lists"}