{"id":20906211,"url":"https://github.com/webpack-config/webpack-config-intl","last_synced_at":"2025-07-03T22:06:06.439Z","repository":{"id":143928181,"uuid":"81034206","full_name":"webpack-config/webpack-config-intl","owner":"webpack-config","description":null,"archived":false,"fork":false,"pushed_at":"2017-02-24T22:21:24.000Z","size":9,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-26T19:48:20.119Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/webpack-config.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-06T01:02:25.000Z","updated_at":"2017-02-06T03:49:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"c9e949e6-b967-472f-a1ac-ede25e1e3f89","html_url":"https://github.com/webpack-config/webpack-config-intl","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"3527af3abdbad504ed8534301cc69428b8f3cacc"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/webpack-config/webpack-config-intl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-config%2Fwebpack-config-intl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-config%2Fwebpack-config-intl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-config%2Fwebpack-config-intl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-config%2Fwebpack-config-intl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webpack-config","download_url":"https://codeload.github.com/webpack-config/webpack-config-intl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-config%2Fwebpack-config-intl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263410769,"owners_count":23462298,"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-11-18T13:32:30.054Z","updated_at":"2025-07-03T22:06:06.400Z","avatar_url":"https://github.com/webpack-config.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#webpack-config-intl\n\nAdd support for intl to your [webpack] build.\n\n[![build status](http://img.shields.io/travis/webpack-config/webpack-config-intl/master.svg?style=flat)](https://travis-ci.org/webpack-config/webpack-config-intl)\n[![coverage](http://img.shields.io/coveralls/webpack-config/webpack-config-intl/master.svg?style=flat)](https://coveralls.io/github/webpack-config/webpack-config-intl?branch=master)\n[![license](http://img.shields.io/npm/l/webpack-config-intl.svg?style=flat)](https://www.npmjs.com/package/webpack-config-intl)\n[![version](http://img.shields.io/npm/v/webpack-config-intl.svg?style=flat)](https://www.npmjs.com/package/webpack-config-intl)\n[![downloads](http://img.shields.io/npm/dm/webpack-config-intl.svg?style=flat)](https://www.npmjs.com/package/webpack-config-intl)\n\n## Usage\n\nInstall:\n```sh\nnpm install --save webpack-config-intl\n```\n\nAdd to your `webpack.config.babel.js`:\n\n```js\nimport intl from `webpack-config-intl`;\n\n// Optional messagesDir config option specifying the location of yaml message\n// files.\nintl({messagesDir: 'intl/messages'})({\n  /* existing webpack configuration */\n})\n```\n\nLoad intl data and messages dynamically in your app:\n\n```js\n// intl.action.js\nimport {loadLocaleData, loadMessages} from 'webpack-config-intl/chunk-loader';\n\nexport const loadLocale = (locale) =\u003e (dispatch) =\u003e\n  Promise.all([loadMessages(locale), loadLocaleData(locale)])\n    .then(([messages]) =\u003e dispatch({\n      type: 'LOCALE_LOADED',\n      payload: {locale, messages},\n    }));\n```\n\n```js\n// intl.reducer.js\nconst initialState = {\n  messages: {},\n  locale: process.env.DEFAULT_LOCALE,\n};\n\nexport default (state = initialState, action) =\u003e {\n  switch (action.type) {\n  case 'LOCALE_LOADED':\n    return pick(['messages', 'locale'], action.payload);\n  default:\n    return state;\n  }\n};\n```\n\nProvide the loaded intl data to your components:\n\n```jsx\nimport {createElement} from 'react';\nimport setDisplayName from 'recompose/setDisplayName';\nimport {connect} from 'react-redux';\nimport {IntlProvider} from 'react-intl';\n\nexport const App = ({locale, messages, children, ...props}) =\u003e\n  \u003cIntlProvider\n    // By default, changes to the locale at runtime may not trigger a re-render\n    // of child elements. Adding a `key` prop that changes with the locale\n    // pursuades React to re-render the component tree.\n    key={locale}\n    locale={locale}\n    messages={messages}\n    defaultLocale={'en'}\n    children={children}\n    {...props}\n  \u003e\n    // ...\n  \u003c/IntlProvider\u003e\n\nconst mapState = (state) =\u003e ({\n  locale: state.intl.locale,\n  messages: state.intl.messages,\n)};\n\nexport default connect(mapState, null)(App);\n```\n\n[webpack]: https://webpack.github.io","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack-config%2Fwebpack-config-intl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebpack-config%2Fwebpack-config-intl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack-config%2Fwebpack-config-intl/lists"}