{"_id":"@brain-toolkit/ts2locales","_rev":"5-d8efa7ba1195abf7d45a66578bd79edc","name":"@brain-toolkit/ts2locales","dist-tags":{"latest":"0.4.0"},"versions":{"0.2.3":{"name":"@brain-toolkit/ts2locales","version":"0.2.3","keywords":["brain toolkit","ts2locales","ts2locales","ViteTsToLocales"],"author":{"name":"qlover"},"license":"ISC","_id":"@brain-toolkit/ts2locales@0.2.3","maintainers":[{"name":"maroonlis","email":"myused@sina.com"}],"homepage":"https://github.com/qlover/brain-toolkit#readme","bugs":{"url":"https://github.com/qlover/brain-toolkit/issues"},"dist":{"shasum":"07c602fb85c26f0ba9eb139914874932edc4663a","tarball":"https://registry.npmjs.org/@brain-toolkit/ts2locales/-/ts2locales-0.2.3.tgz","fileCount":15,"integrity":"sha512-JzDMaic51vtR9vRxS5TA7AMlZxqx3G8UV9clMiev2bWen9irOVRFJ+CPmJphRbs18zJPv9OrSFN4BjtNfc8SVQ==","signatures":[{"sig":"MEYCIQCtkKPFulHNWYD/2VR9nlHGp6AwcV571WazrWLqttjNlwIhALNBX4FGQlvTimGMv6LbayRoQhrvMw9fO6V4lx/RMeA5","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":99403},"main":"./dist/index.cjs","type":"module","_from":"file:brain-toolkit-ts2locales-0.2.3.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./vite":{"types":"./dist/vite/index.d.ts","import":"./dist/vite/index.js","require":"./dist/vite/index.cjs"},"./package.json":"./package.json"},"private":false,"scripts":{"build":"tsup"},"_npmUser":{"name":"maroonlis","email":"myused@sina.com"},"_resolved":"/tmp/55550606b65a6ed27a8ffc196ab40159/brain-toolkit-ts2locales-0.2.3.tgz","_integrity":"sha512-JzDMaic51vtR9vRxS5TA7AMlZxqx3G8UV9clMiev2bWen9irOVRFJ+CPmJphRbs18zJPv9OrSFN4BjtNfc8SVQ==","repository":{"url":"git+https://github.com/qlover/brain-toolkit.git","type":"git","directory":"packages/ts2locales"},"_npmVersion":"10.5.0","description":"`@brain-toolkit/ts2locales` 是一个用于从 TypeScript 文件中提取国际化信息并生成本地化文件的工具。它可以帮助你管理多语言翻译，使国际化过程更加简单和规范。","directories":{},"_nodeVersion":"18.20.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^6.1.0"},"_npmOperationalInternal":{"tmp":"tmp/ts2locales_0.2.3_1749092928176_0.7543237904049114","host":"s3://npm-registry-packages-npm-production"}},"0.2.4":{"name":"@brain-toolkit/ts2locales","version":"0.2.4","keywords":["brain toolkit","ts2locales","ts2locales","ViteTsToLocales"],"author":{"name":"qlover"},"license":"ISC","_id":"@brain-toolkit/ts2locales@0.2.4","maintainers":[{"name":"maroonlis","email":"myused@sina.com"}],"homepage":"https://github.com/qlover/brain-toolkit#readme","bugs":{"url":"https://github.com/qlover/brain-toolkit/issues"},"dist":{"shasum":"608e361512319ada41f99731b396b02dcbc23ba8","tarball":"https://registry.npmjs.org/@brain-toolkit/ts2locales/-/ts2locales-0.2.4.tgz","fileCount":15,"integrity":"sha512-H+gk4KELHV9BC6Km541S4Ul8Am13et1Yu+ENH0MS6Pl60WZz4VkUE+Ht1ss2dYLYNA2a1G6ITzKpMPvksH7l9g==","signatures":[{"sig":"MEUCIQC85YjCc4EiJ2aLZTwMx+WbBzE/BQ665EhKIPP74E6QiwIgeXWPB9fLNqoV7caIW+yFShsfiGwjBPfDNxHn23x10OI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":87045},"main":"./dist/index.cjs","type":"module","_from":"file:brain-toolkit-ts2locales-0.2.4.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./vite":{"types":"./dist/vite/index.d.ts","import":"./dist/vite/index.js","require":"./dist/vite/index.cjs"},"./package.json":"./package.json"},"private":false,"scripts":{"build":"tsup"},"_npmUser":{"name":"maroonlis","email":"myused@sina.com"},"_resolved":"/tmp/e65918a006cce325ad59a76a74c82963/brain-toolkit-ts2locales-0.2.4.tgz","_integrity":"sha512-H+gk4KELHV9BC6Km541S4Ul8Am13et1Yu+ENH0MS6Pl60WZz4VkUE+Ht1ss2dYLYNA2a1G6ITzKpMPvksH7l9g==","repository":{"url":"git+https://github.com/qlover/brain-toolkit.git","type":"git","directory":"packages/ts2locales"},"_npmVersion":"10.5.0","description":"`@brain-toolkit/ts2locales` 是一个用于从 TypeScript 文件中提取国际化信息并生成本地化文件的工具。它可以帮助你管理多语言翻译，使国际化过程更加简单和规范。","directories":{},"_nodeVersion":"18.20.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^6.1.0"},"_npmOperationalInternal":{"tmp":"tmp/ts2locales_0.2.4_1762151124563_0.9088502521000925","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@brain-toolkit/ts2locales","version":"0.3.0","keywords":["brain toolkit","ts2locales","ts2locales","ViteTsToLocales"],"author":{"name":"qlover"},"license":"ISC","_id":"@brain-toolkit/ts2locales@0.3.0","maintainers":[{"name":"maroonlis","email":"myused@sina.com"}],"homepage":"https://github.com/qlover/brain-toolkit#readme","bugs":{"url":"https://github.com/qlover/brain-toolkit/issues"},"dist":{"shasum":"f2c81ded1ceab4b1b027ddc6dc25bc76375f90e6","tarball":"https://registry.npmjs.org/@brain-toolkit/ts2locales/-/ts2locales-0.3.0.tgz","fileCount":15,"integrity":"sha512-ZRtl1fC7/syAeXXzRWY4OMZs7ZmHzssT04KjKOE0s4tvFd7I3ujjN/Vzyr6QB5pdb6gb2mgD2SKW2woEhC+1LQ==","signatures":[{"sig":"MEUCIQDmA65ZaYH7Nhvk9Nfqy6DiBJ/qiKQ9udl8/IUFyv9gJwIgWmq3rfTK0qwwyd5X+tOCfVGUwZ0rHu5Jkg6AGBSt7hg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":85606},"main":"./dist/index.cjs","type":"module","_from":"file:brain-toolkit-ts2locales-0.3.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./vite":{"types":"./dist/vite/index.d.ts","import":"./dist/vite/index.js","require":"./dist/vite/index.cjs"},"./package.json":"./package.json"},"private":false,"scripts":{"build":"tsup","type-check":"tsc --build"},"_npmUser":{"name":"maroonlis","email":"myused@sina.com"},"_resolved":"/tmp/35d55847d5cb9a3c1ec6bedda652934e/brain-toolkit-ts2locales-0.3.0.tgz","_integrity":"sha512-ZRtl1fC7/syAeXXzRWY4OMZs7ZmHzssT04KjKOE0s4tvFd7I3ujjN/Vzyr6QB5pdb6gb2mgD2SKW2woEhC+1LQ==","repository":{"url":"git+https://github.com/qlover/brain-toolkit.git","type":"git","directory":"packages/ts2locales"},"_npmVersion":"10.5.0","description":"`@brain-toolkit/ts2locales` 是一个用于从 TypeScript 文件中提取国际化信息并生成本地化文件的工具。它可以帮助你管理多语言翻译，使国际化过程更加简单和规范。","directories":{},"_nodeVersion":"18.20.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^6.1.0"},"_npmOperationalInternal":{"tmp":"tmp/ts2locales_0.3.0_1766480799397_0.8316782379687779","host":"s3://npm-registry-packages-npm-production"}},"0.3.1":{"name":"@brain-toolkit/ts2locales","version":"0.3.1","keywords":["brain toolkit","ts2locales","ts2locales","ViteTsToLocales"],"author":{"name":"qlover"},"license":"ISC","_id":"@brain-toolkit/ts2locales@0.3.1","maintainers":[{"name":"maroonlis","email":"myused@sina.com"}],"homepage":"https://github.com/qlover/brain-toolkit#readme","bugs":{"url":"https://github.com/qlover/brain-toolkit/issues"},"dist":{"shasum":"2f49177f28001dbbcaa61b104c4a63c0a1ecddc7","tarball":"https://registry.npmjs.org/@brain-toolkit/ts2locales/-/ts2locales-0.3.1.tgz","fileCount":15,"integrity":"sha512-vdnqfGt297A+abp0EzxPUxklAR3pXTMyayZdCxwawJvsxmY1RUQdzkuvE/3ZQmJS89WJ+pD9pdR+CYXg4u1T6g==","signatures":[{"sig":"MEUCIHXjkyEDyXCYV6L/bmIYeo2CF+kBcEBpofyo889M66T2AiEAyJSw+nnBnJLAcD3Sss7Z/dkGgMIr2sobQEoex4UdNHA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":86377},"main":"./dist/index.cjs","type":"module","_from":"file:brain-toolkit-ts2locales-0.3.1.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./vite":{"types":"./dist/vite/index.d.ts","import":"./dist/vite/index.js","require":"./dist/vite/index.cjs"},"./package.json":"./package.json"},"private":false,"scripts":{"build":"tsup","type-check":"tsc --build"},"_npmUser":{"name":"maroonlis","email":"myused@sina.com"},"_resolved":"/tmp/dbb0a0b815af44bb6cbb96a5b62de704/brain-toolkit-ts2locales-0.3.1.tgz","_integrity":"sha512-vdnqfGt297A+abp0EzxPUxklAR3pXTMyayZdCxwawJvsxmY1RUQdzkuvE/3ZQmJS89WJ+pD9pdR+CYXg4u1T6g==","repository":{"url":"git+https://github.com/qlover/brain-toolkit.git","type":"git","directory":"packages/ts2locales"},"_npmVersion":"10.5.0","description":"`@brain-toolkit/ts2locales` 是一个用于从 TypeScript 文件中提取国际化信息并生成本地化文件的工具。它可以帮助你管理多语言翻译，使国际化过程更加简单和规范。","directories":{},"_nodeVersion":"18.20.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^6.1.0"},"_npmOperationalInternal":{"tmp":"tmp/ts2locales_0.3.1_1766502039196_0.9140278943608038","host":"s3://npm-registry-packages-npm-production"}},"0.4.0":{"name":"@brain-toolkit/ts2locales","version":"0.4.0","type":"module","private":false,"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{"./package.json":"./package.json",".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./vite":{"types":"./dist/vite/index.d.ts","import":"./dist/vite/index.js","require":"./dist/vite/index.cjs"}},"repository":{"type":"git","url":"git+https://github.com/qlover/brain-toolkit.git","directory":"packages/ts2locales"},"homepage":"https://github.com/qlover/brain-toolkit#readme","keywords":["brain toolkit","ts2locales","ts2locales","ViteTsToLocales"],"author":{"name":"qlover"},"license":"ISC","publishConfig":{"access":"public"},"devDependencies":{"vite":"^7.2.4"},"scripts":{"build":"tsup","type-check":"tsc --build"},"description":"`@brain-toolkit/ts2locales` 是一个用于从 TypeScript 文件中提取国际化信息并生成本地化文件的工具。它可以帮助你管理多语言翻译，使国际化过程更加简单和规范。","bugs":{"url":"https://github.com/qlover/brain-toolkit/issues"},"_id":"@brain-toolkit/ts2locales@0.4.0","_integrity":"sha512-NiP7GM/DWuETGx1xX2/9RLDSnhUMaO95RsK3sY/mO82iikxqTHPZLrDvugzwWUA6FHOEtYxY3G5UxRxxwHB6RA==","_resolved":"/tmp/92156391d56bba68ffec2c534dc8eb5e/brain-toolkit-ts2locales-0.4.0.tgz","_from":"file:brain-toolkit-ts2locales-0.4.0.tgz","_nodeVersion":"18.20.0","_npmVersion":"10.5.0","dist":{"integrity":"sha512-NiP7GM/DWuETGx1xX2/9RLDSnhUMaO95RsK3sY/mO82iikxqTHPZLrDvugzwWUA6FHOEtYxY3G5UxRxxwHB6RA==","shasum":"74acd38a15f25b96ae107df806e3c89ae32851d5","tarball":"https://registry.npmjs.org/@brain-toolkit/ts2locales/-/ts2locales-0.4.0.tgz","fileCount":15,"unpackedSize":109473,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCH0Uc65ZWwbFXUmHOrwh040zEADbu6EJupFJnxPM2e88CIQDZbcmhbzhD4LS2Se2iB2mqM2XSIgFoeohOA7/C86/6Lw=="}]},"_npmUser":{"name":"maroonlis","email":"myused@sina.com"},"directories":{},"maintainers":[{"name":"maroonlis","email":"myused@sina.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ts2locales_0.4.0_1770278106517_0.23217170224235506"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-05T03:08:48.103Z","modified":"2026-02-05T07:55:06.791Z","0.2.3":"2025-06-05T03:08:48.373Z","0.2.4":"2025-11-03T06:25:24.846Z","0.3.0":"2025-12-23T09:06:39.563Z","0.3.1":"2025-12-23T15:00:39.353Z","0.4.0":"2026-02-05T07:55:06.671Z"},"bugs":{"url":"https://github.com/qlover/brain-toolkit/issues"},"author":{"name":"qlover"},"license":"ISC","homepage":"https://github.com/qlover/brain-toolkit#readme","keywords":["brain toolkit","ts2locales","ts2locales","ViteTsToLocales"],"repository":{"type":"git","url":"git+https://github.com/qlover/brain-toolkit.git","directory":"packages/ts2locales"},"description":"`@brain-toolkit/ts2locales` 是一个用于从 TypeScript 文件中提取国际化信息并生成本地化文件的工具。它可以帮助你管理多语言翻译，使国际化过程更加简单和规范。","maintainers":[{"name":"maroonlis","email":"myused@sina.com"}],"readme":"# @brain-toolkit/ts2locales\n\n`@brain-toolkit/ts2locales` 是一个用于从 TypeScript 文件中提取国际化信息并生成本地化文件的工具。它可以帮助你管理多语言翻译，使国际化过程更加简单和规范。\n\n## 特性\n\n- 从 TypeScript 文件中提取国际化信息\n- 支持多语言本地化文件生成\n- 自动合并已存在的翻译文件\n- 支持 JSDoc 注释中的翻译说明\n- 支持 Vite 插件集成\n\n## 安装\n\n```bash\nnpm install @brain-toolkit/ts2locales --save-dev\n# 或\nyarn add @brain-toolkit/ts2locales -D\n# 或\npnpm add @brain-toolkit/ts2locales -D\n```\n\n## 使用方法\n\n### 1. 在 TypeScript 文件中定义国际化内容\n\n在你的 TypeScript 文件中使用特定格式的 JSDoc 注释来定义国际化内容：\n\n```typescript\n/**\n * @description 用户名不能为空\n * @localZh 用户名不能为空\n * @localEn Username cannot be empty\n */\nexport const USERNAME_EMPTY = 'error.username.empty';\n\n/**\n * @description 密码长度必须大于 6 位\n * @localZh 密码长度必须大于 6 位\n * @localEn Password must be longer than 6 characters\n */\nexport const PASSWORD_TOO_SHORT = 'error.password.length';\n```\n\n### 2. 使用 API\n\n```typescript\nimport { Ts2Locales } from '@brain-toolkit/ts2locales';\n\nconst ts2locales = new Ts2Locales(['zh', 'en']);\n\nawait ts2locales.generate({\n  source: './src/constants/errors.ts',\n  target: './src/locales/{{lng}}/errors.json'\n});\n```\n\n### 3. 在 Vite 中使用\n\n```typescript\n// vite.config.ts\nimport { defineConfig } from 'vite';\nimport { ts2localesVitePlugin } from '@brain-toolkit/ts2locales/vite';\n\nexport default defineConfig({\n  plugins: [\n    ts2localesVitePlugin({\n      locales: ['zh', 'en'],\n      values: [\n        {\n          source: './src/constants/errors.ts',\n          target: './src/locales/{{lng}}/errors.json'\n        }\n      ]\n    })\n  ]\n});\n```\n\n## 配置说明\n\n### Ts2Locales 构造函数\n\n- `locales`: string[] - 支持的语言代码数组，例如 `['zh', 'en']`\n\n### generate 方法参数\n\n- `source`: string - 源文件路径\n- `target`: string - 目标文件路径，使用 `{{lng}}` 作为语言代码占位符\n\n### Vite 插件配置\n\n- `locales`: string[] - 支持的语言代码数组\n- `values`: Array<{ source: string; target: string }> - 源文件和目标文件的映射配置\n\n## 生成的文件示例\n\n对于上述示例代码，将会生成如下格式的本地化文件：\n\n```json\n// locales/zh/errors.json\n{\n  \"error.username.empty\": \"用户名不能为空\",\n  \"error.password.length\": \"密码长度必须大于 6 位\"\n}\n\n// locales/en/errors.json\n{\n  \"error.username.empty\": \"Username cannot be empty\",\n  \"error.password.length\": \"Password must be longer than 6 characters\"\n}\n```\n\n## 注意事项\n\n1. 源文件中的 JSDoc 注释必须包含 `@description` 标签\n2. 语言特定的翻译使用 `@local` 前缀，如 `@localZh`、`@localEn` 等\n3. 如果某个语言没有提供翻译，将使用 `description` 作为默认值\n4. 生成的本地化文件会自动合并已存在的翻译，不会覆盖未更新的内容\n","readmeFilename":"README.md"}