{"id":18151982,"url":"https://github.com/porky-chen/i18n-t","last_synced_at":"2025-07-25T00:36:56.010Z","repository":{"id":259917376,"uuid":"879823376","full_name":"porky-chen/i18n-t","owner":"porky-chen","description":"A Vue SDK for batch multi-language translation using Youdao API, auto-extracting text for i18n localization.","archived":false,"fork":false,"pushed_at":"2024-10-28T16:53:50.000Z","size":1904,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T05:44:19.173Z","etag":null,"topics":["batch-translation","i18n","json","localization","multi-language","sdk","text-extraction","translation","vue","youdao-api"],"latest_commit_sha":null,"homepage":"https://porky-chen.github.io/zeoblog","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/porky-chen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2024-10-28T15:55:54.000Z","updated_at":"2024-10-28T17:00:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"fa6551b4-1e04-47ad-b857-8b638e00db7f","html_url":"https://github.com/porky-chen/i18n-t","commit_stats":null,"previous_names":["porky-chen/i18n-t"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porky-chen%2Fi18n-t","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porky-chen%2Fi18n-t/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porky-chen%2Fi18n-t/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porky-chen%2Fi18n-t/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/porky-chen","download_url":"https://codeload.github.com/porky-chen/i18n-t/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247569130,"owners_count":20959758,"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":["batch-translation","i18n","json","localization","multi-language","sdk","text-extraction","translation","vue","youdao-api"],"created_at":"2024-11-02T02:05:12.747Z","updated_at":"2025-04-06T23:45:18.806Z","avatar_url":"https://github.com/porky-chen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# i18n-t SDK\n\n  \n\n一个简单的 SDK，用于提取和翻译 Vue.js 项目内的文本内容。此 SDK 可识别 Vue 模板和脚本中用 `$t('...')` 包裹的文本，并使用有道 API 跨多种语言执行批量翻译。\n\n## Features\n\n  \n\n- **自动文本提取**：识别 Vue 文件中的翻译键，搜索模板中的 `$t('...')` 和脚本中的 `this.$t('...')`。\n\n- **批量翻译**：支持将提取的文本翻译成多种目标语言。\n\n- **多语言 JSON 输出**：为每个目标语言生成独立的 JSON 文件，方便与支持 i18n 的项目集成。\n\n  \n\n## Installation\n\n  \n\nTo install this SDK, clone the repository and install dependencies:\n\n  \n\n```bash\ngit  clone  https://github.com/porky-chen/i18n-t.git\n\ncd  i18n-t\n\nnpm  install\n```\n\n**使用方法**\n\n**1. 提取和翻译键**\n\ntranslateKeys 函数接收一个键数组和目标语言列表，获取每个键的翻译，并为每种语言单独存储翻译内容。\n\n**2. 保存翻译**\n\nsaveTranslations 函数将每种语言的翻译写入 translations.{lang}.json 格式的 JSON 文件中。\n\n**使用示例**\n```javascript\nconst { translateKeys, saveTranslations } = require('./translate-sdk');\n\n(async () =\u003e {\n    const keys = [\n        '您好，欢迎再次使用有道智云文本翻译API接口服务',\n        '这是另一段测试内容'\n    ];\n    const targetLanguages = ['en', 'fr', 'es'];\n\n    // 执行翻译并保存为多语言 JSON 文件\n    const translations = await translateKeys(keys, targetLanguages);\n    await saveTranslations(translations, targetLanguages);\n})();\n```\n\n**API 密钥配置**\n\n要使用有道翻译 API，请直接在 translate.js 中配置 appKey 和 secretKey。**请确保不要公开暴露这些密钥**，以免造成潜在的安全风险。\n\n**依赖项**\n\n - axios: 用于向有道 API 发送请求。\n - fs-extra: 便于文件操作。\n - crypto-js: 用于生成安全的 API 请求签名。\n - uuid: 用于生成随机数\n\n**许可证**\n该项目基于 MIT 许可证。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fporky-chen%2Fi18n-t","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fporky-chen%2Fi18n-t","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fporky-chen%2Fi18n-t/lists"}