{"id":18776190,"url":"https://github.com/jaredleechn/atool-i18n","last_synced_at":"2025-12-15T11:30:21.413Z","repository":{"id":176582130,"uuid":"60690400","full_name":"jaredleechn/atool-i18n","owner":"jaredleechn","description":"deprecated, more update in https://github.com/ant-tool/atool-l10n","archived":false,"fork":false,"pushed_at":"2016-06-24T03:45:43.000Z","size":18,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-29T09:26:28.012Z","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/jaredleechn.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":"2016-06-08T10:38:49.000Z","updated_at":"2024-12-05T08:53:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"114aec30-2053-4d3f-9297-9240afeb67c6","html_url":"https://github.com/jaredleechn/atool-i18n","commit_stats":null,"previous_names":["jaredleechn/atool-i18n"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredleechn%2Fatool-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredleechn%2Fatool-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredleechn%2Fatool-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredleechn%2Fatool-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaredleechn","download_url":"https://codeload.github.com/jaredleechn/atool-i18n/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239683878,"owners_count":19680034,"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-07T19:45:13.272Z","updated_at":"2025-12-15T11:30:16.125Z","avatar_url":"https://github.com/jaredleechn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# intl-translate\n\nautomatical workflow to solve intl resource load problem.\n\n- collect intl messages meta data generated by plugin like `babel-plugin-react-intl`\n\n- fetch suggestion for each language\n\n- pick the best translation\n\n- save into local locale files, which are required directly by source code\n\n![](https://zos.alipayobjects.com/rmsportal/fbNVmbWsFCnArWZ.png)\n\n\n## Usage\n\n\n- setup\n\n  ```bash\n  $ npm i intl-translate --save-dev\n  ```\n- `intl.config.js`\n\n  ```js\n  module.exports = function (config) {\n    return Object.assign({},\n      config,\n      {\n        middleware: {\n          pre: 'summary?source=i18n-messages',\n          process: ['youdao?langs[]=cn,langs[]=en', 'reduce?local=locales'],\n          emit: 'save?dest=locales',\n        },\n      }\n    );\n  };\n  ```\n- run\n\n  ```bash\n  $ node_modules/.bin/intl-translate\n  ```\n\n## Options\n\n```bash\n\n  Usage: intl-translate [options]\n\n  Options:\n\n    -h, --help      output usage information\n    -v, --version   output the version number\n    --config \u003cdir\u003e  where is the config file, default is intl.config.js\n\n```\n\n## Middleware\n\n`intl-translate` middlewares will execute one by one, with three parameters:\n\n```\nplugins.reduce((a, b) =\u003e {\n  if (a instanceof Promise) {\n    return a.then(result =\u003e b.plugin(result, b.query, context));\n  }\n  return b.plugin(a, b.query, context);\n}, Promise.resolve());\n```\n\n- result: return value of previous middleware\n- query: parameters passed to current middleware, parse from `option.config(default is intl.config.js)`\n- context: intl-translate context\n\n#### Life cycle\n\nMiddlewares contains three stage, each stage share the same data structure\n\n|middleware stage|default|description|\n|:---:|:---:|:---:|\n|pre|summary|collect origin data generated from `babel-plugin-react-intl` or something else|\n|process|google, pick|loading translation from cloud or translate center and fill into result with key of language|\n|emit|save|emit into locales resource|\n\n#### Built-in middlewares\n\n`summary`: collect origin data generated from `babel-plugin-react-intl`\n\nreturns:\n```\n[{\n  id: 'totalPrice',\n  description: '展示订单总额',\n  defaultMessage: '订单全额'\n}, {\n  id: 'count',\n  description: '显示订单中商品数量',\n  defaultMessage: '数量'\n}]\n```\n\n|parameter|default|description|\n|:---:|:---:|:---:|\n|cwd|context.cwd||\n|source|'i18n-messages'|where is the messages folder|\n|patten|'**/*.json'|patten of json files|\n\n\n`google`: add translate result for each language from google\n\nreturns: \n```\n[{\n  id: 'totalPrice',\n  description: '展示订单总额',\n  defaultMessage: '订单全额',\n  cn: ['订单总价', '订单全额', '订单价格'],\n  en: ['totalPrices', 'totalPrice']\n}, {\n  id: 'count',\n  description: '显示订单中商品数量',\n  defaultMessage: '数量',\n  cn: ['数量', '数目'],\n  en: 'count'\n}]\n```\n\n|parameter|default|description|\n|:---:|:---:|:---:|\n|langs|[]|languages you need to translate|\n\n\n`educe`: pick the best translation of each id in terminal\n\nreturns:\n\n```\n[{\n  id: 'totalPrice',\n  description: '展示订单总额',\n  defaultMessage: '订单全额',\n  cn: '订单总价',\n  en: 'totalPrice'\n}, {\n  id: 'count',\n  description: '显示订单中商品数量',\n  defaultMessage: '数量',\n  cn: '数目',\n  en: 'count'\n}]\n```\n\n|parameter|default|description|\n|:---:|:---:|:---:|\n|local|'locales'|add local files into suggestion|\n\n`save`: save into json\n\nreturns: true || false\n\n|parameter|default|description|\n|:---:|:---:|:---:|\n|dest|'locales'|save to where|","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredleechn%2Fatool-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaredleechn%2Fatool-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredleechn%2Fatool-i18n/lists"}