{"id":16798820,"url":"https://github.com/marvelsq/extract-locale","last_synced_at":"2025-03-17T04:41:18.795Z","repository":{"id":76599267,"uuid":"604919609","full_name":"MarvelSQ/extract-locale","owner":"MarvelSQ","description":"extract string to formatMessage()","archived":false,"fork":false,"pushed_at":"2023-06-13T03:55:49.000Z","size":405,"stargazers_count":0,"open_issues_count":8,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-08T18:34:22.429Z","etag":null,"topics":["i18n","internationalization","localization"],"latest_commit_sha":null,"homepage":"https://extract-locale.vercel.app","language":"TypeScript","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/MarvelSQ.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":"2023-02-22T03:48:55.000Z","updated_at":"2023-05-05T08:29:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"6b90edfc-89bd-46be-a5d2-a5b8db1f65ca","html_url":"https://github.com/MarvelSQ/extract-locale","commit_stats":null,"previous_names":["marvelsq/extract-local"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarvelSQ%2Fextract-locale","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarvelSQ%2Fextract-locale/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarvelSQ%2Fextract-locale/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarvelSQ%2Fextract-locale/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarvelSQ","download_url":"https://codeload.github.com/MarvelSQ/extract-locale/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243976644,"owners_count":20377695,"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":["i18n","internationalization","localization"],"created_at":"2024-10-13T09:26:59.985Z","updated_at":"2025-03-17T04:41:18.763Z","avatar_url":"https://github.com/MarvelSQ.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# extract-locale\n\n使用 babel 自动收集未翻译的文案 并替换为 formatMessage\n\n源文件\n\n```jsx\nconst App = (user) =\u003e {\n  return (\n    \u003cdiv\u003e\n      \u003cdiv\u003e用户名: {user.name}\u003c/div\u003e\n      \u003cdiv\u003e地址: {user.adderss}\u003c/div\u003e\n    \u003c/div\u003e\n  );\n};\n```\n\n执行该命令\n\n```bash\nextract-locale ./src/**/*.{ts,tsx}\n```\n\n编译后的文件\n\n```jsx\nimport { useIntl } from \"xxx/IntlProvider\";\n\nconst App = (user) =\u003e {\n  const intl = useIntl();\n  return (\n    \u003cdiv\u003e\n      \u003cdiv\u003e\n        {intl.formatMessage(\"@LOCALE_TEXT_0\")} {user.name}\n      \u003c/div\u003e\n      \u003cdiv\u003e\n        {intl.formatMessage(\"@LOCALE_TEXT_0\")} {user.adderss}\n      \u003c/div\u003e\n    \u003c/div\u003e\n  );\n};\n```\n\n对应的文案\n\n```json\n{\n  \"@LOCALE_TEXT_0\": \"用户名:\",\n  \"@LOCALE_TEXT_1\": \"地址:\"\n}\n```\n\n### 参数\n\n主要参数为 文件匹配符\n\n| 参数              | 缩写 | 描述                              |\n| ----------------- | ---- | --------------------------------- |\n| --locale \u003clocale\u003e | -l   | 输入已存在的 localemap            |\n| --prefix \u003cprefix\u003e | -p   | 国际化文案的前缀(`@LOCALE_TEXT_`) |\n| --offset \u003coffset\u003e | -o   | 起始序号(`0`)                     |\n| --no-auto         | -A   | 是否禁止自动替换(`false`)         |\n| --no-auto-name    |      | 是否禁止自动命名(`false`)         |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarvelsq%2Fextract-locale","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarvelsq%2Fextract-locale","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarvelsq%2Fextract-locale/lists"}