{"id":13739989,"url":"https://github.com/hustcc/babel-plugin-optimize-i18n","last_synced_at":"2025-03-19T14:30:43.701Z","repository":{"id":66093465,"uuid":"153581771","full_name":"hustcc/babel-plugin-optimize-i18n","owner":"hustcc","description":":key: 优化国际化文案的 Babel 插件，可以减少国际化文案 40% ~ 50% 的 bundle size。","archived":false,"fork":false,"pushed_at":"2018-11-01T08:32:49.000Z","size":10,"stargazers_count":14,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T19:12:02.495Z","etag":null,"topics":["babel-plugin","i18n","optimize-i18n"],"latest_commit_sha":null,"homepage":"https://github.com/hustcc/babel-plugin-optimize-i18n","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/hustcc.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":"2018-10-18T07:29:43.000Z","updated_at":"2024-06-25T14:51:31.000Z","dependencies_parsed_at":"2023-03-10T23:36:53.752Z","dependency_job_id":null,"html_url":"https://github.com/hustcc/babel-plugin-optimize-i18n","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":"0.11111111111111116","last_synced_commit":"6d039dec355e259a52c22415a255ed018f474a40"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hustcc%2Fbabel-plugin-optimize-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hustcc%2Fbabel-plugin-optimize-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hustcc%2Fbabel-plugin-optimize-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hustcc%2Fbabel-plugin-optimize-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hustcc","download_url":"https://codeload.github.com/hustcc/babel-plugin-optimize-i18n/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243997041,"owners_count":20380980,"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":["babel-plugin","i18n","optimize-i18n"],"created_at":"2024-08-03T04:00:40.922Z","updated_at":"2025-03-19T14:30:43.692Z","avatar_url":"https://github.com/hustcc.png","language":"JavaScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Optimization"],"readme":"# babel-plugin-optimize-i18n\n\nA babel plugin for optimizing i18n locales file which can reduce 40% ~ 50% bundle size.\n\n[![npm](https://img.shields.io/npm/v/babel-plugin-optimize-i18n.svg)](https://www.npmjs.com/package/babel-plugin-optimize-i18n)\n[![npm download](https://img.shields.io/npm/dm/babel-plugin-optimize-i18n.svg)](https://www.npmjs.com/package/babel-plugin-optimize-i18n)\n\n\n## Install\n\n\n\u003e npm i --save-dev babel-plugin-optimize-i18n\n\n\n\n## Usage\n\n\nAdd it into `.babelrc`.\n\n```json\n{\n  \"plugins\": [\n    \"optimize-i18n\"\n  ]\n}\n```\n\n\n\n## Result\n\n\nThe source i18n text file below:\n\n```json\n{\n  \"module.left.title\": \"左侧标题\",\n  \"module.right.title\": \"右侧标题\"\n}\n```\n\nwill be transformed to:\n\n```js\n{\n  $1: \"左侧标题\",\n  $2: \"右侧标题\"\n}\n```\n\n\n\n## Configure\n\n\nYou can customize the configure of the plugin.\n\n```js\n{\n  localeFiles: ['zh_CN', 'en_US'],\n  i18nFunction: {\n    object: 'intl',\n    property: 'get'\n  },\n  uniquePrefix: '$',\n}\n```\n\n\n\n## Test\n\n\n```\nnpm i\n\nnpm t\n```\n\nThen see the files in `lib` dir.\n\n\n\n## Constraint\n\n\nFor example, when you use the function below to format i18n text.\n\n```js\nintl.get('key', params);\n```\n\nYou should be sure the 1st parameter of `intl.get` is string constant, or will be build error.\n\n\n\n## License\n\nMIT@[hustcc](https://github.com/hustcc).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhustcc%2Fbabel-plugin-optimize-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhustcc%2Fbabel-plugin-optimize-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhustcc%2Fbabel-plugin-optimize-i18n/lists"}