{"id":29322401,"url":"https://github.com/2ue/i18n-x","last_synced_at":"2026-01-20T16:27:11.236Z","repository":{"id":300960528,"uuid":"1005483433","full_name":"2ue/i18n-x","owner":"2ue","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-21T07:01:51.000Z","size":628,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-29T11:29:21.299Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/2ue.png","metadata":{"files":{"readme":"README.en.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,"zenodo":null}},"created_at":"2025-06-20T09:48:47.000Z","updated_at":"2025-08-21T07:01:55.000Z","dependencies_parsed_at":"2025-06-24T13:25:57.260Z","dependency_job_id":"f5e95ffa-0880-4409-a357-f0b99fd9a226","html_url":"https://github.com/2ue/i18n-x","commit_stats":null,"previous_names":["2ue/i18n-x"],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/2ue/i18n-x","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2ue%2Fi18n-x","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2ue%2Fi18n-x/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2ue%2Fi18n-x/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2ue%2Fi18n-x/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/2ue","download_url":"https://codeload.github.com/2ue/i18n-x/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2ue%2Fi18n-x/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28607059,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T16:10:39.856Z","status":"ssl_error","status_checked_at":"2026-01-20T16:10:39.493Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2025-07-07T14:13:02.612Z","updated_at":"2026-01-20T16:27:11.231Z","avatar_url":"https://github.com/2ue.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# i18n-xy\n\nA CLI tool for automatically extracting Chinese strings from React projects and internationalizing them. Supports intelligent string extraction, AST code transformation, key generation, automatic translation, and more.\n\n## ✨ Features\n\n- 🚀 **Automatic Extraction**: Intelligently identifies and extracts Chinese strings from JavaScript/TypeScript/JSX/TSX files\n- 🔄 **Code Transformation**: Uses AST technology to precisely replace Chinese strings with internationalization function calls\n- 🎯 **Smart Key Generation**: Supports pinyin conversion, hash generation, duplicate key detection, and other strategies\n- 🌐 **Automatic Translation**: Integrated with Baidu Translate API for batch translation of internationalization files\n- ⚙️ **Flexible Configuration**: Rich configuration options to meet different project requirements\n- 📁 **File Management**: Supports temporary directory processing to avoid directly modifying source files\n- 🔧 **Auto Import**: Configurable automatic addition of internationalization function import statements\n- 📊 **Detailed Logging**: Multi-level log output for easy debugging and monitoring\n\n## 📦 Installation\n\n```bash\n# Global installation\nnpm install -g i18n-xy\n\n# Or using pnpm\npnpm add -g i18n-xy\n\n# Or using yarn\nyarn global add i18n-xy\n```\n\n## 🚀 Quick Start\n\n### 1. Initialize Configuration\n\n```bash\n# Initialize configuration file\ni18n-xy init\n# Or use short command\ni18nx init\n```\n\n### 2. Extract Chinese Strings\n\n```bash\n# Use default configuration to extract\ni18n-xy extract\n\n# Specify configuration file\ni18n-xy extract -c ./my-config.json\n```\n\n### 3. Translate Internationalization Files\n\n```bash\n# Batch translation\ni18n-xy translate --batch\n\n# Translate single text\ni18n-xy translate --test -f zh -t en -i \"你好世界\"\n```\n\n## ⚙️ Basic Configuration\n\nConfiguration file example (`i18n.config.json`):\n\n```json\n{\n  \"locale\": \"zh-CN\",\n  \"displayLanguage\": \"en-US\",\n  \"outputDir\": \"locales\",\n  \"include\": [\n    \"src/**/*.{js,jsx,ts,tsx}\",\n    \"pages/**/*.{js,jsx,ts,tsx}\",\n    \"components/**/*.{js,jsx,ts,tsx}\"\n  ],\n  \"exclude\": [\n    \"node_modules/**\",\n    \"dist/**\",\n    \"build/**\",\n    \"**/*.test.{js,jsx,ts,tsx}\"\n  ],\n  \"replacement\": {\n    \"functionName\": \"$t\",\n    \"autoImport\": {\n      \"enabled\": true,\n      \"insertPosition\": \"afterImports\"\n    }\n  }\n}\n```\n\n### Core Configuration Options\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `locale` | string | `\"zh-CN\"` | Source language |\n| `outputDir` | string | `\"locales\"` | Internationalization file output directory |\n| `include` | string[] | `[\"src/**/*.{js,jsx,ts,tsx}\"]` | File patterns to process |\n| `exclude` | string[] | `[\"node_modules/**\"]` | File patterns to exclude |\n| `replacement.functionName` | string | `\"$t\"` | Replacement function name |\n\n## 🛠️ Development\n\n### Environment Requirements\n\n- Node.js \u003e= 16.0.0\n- npm/pnpm/yarn\n\n### Local Development\n\n```bash\n# Clone project\ngit clone \u003crepository-url\u003e\ncd i18n-xy\n\n# Install dependencies\npnpm install\n\n# Development mode\npnpm dev\n\n# Build\npnpm build\n\n# Code check\npnpm lint\n\n# Type check\npnpm type-check\n```\n\n### Project Structure\n\n```\nsrc/\n├── ast/           # AST processing core logic\n├── cli.ts         # CLI command line entry\n├── config/        # Configuration management\n├── translation/   # Translation functionality\n├── utils/         # Utility functions\n└── vars/          # Variable management\n```\n\n## 📚 Usage Examples\n\n### Before Processing\n\n```javascript\nfunction Welcome({ name }) {\n  return (\n    \u003cdiv\u003e\n      \u003ch1\u003e欢迎使用我们的系统\u003c/h1\u003e\n      \u003cp\u003e用户：{name}，您好！\u003c/p\u003e\n      \u003cbutton onClick={handleClick}\u003e点击开始\u003c/button\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n### After Processing\n\n```javascript\nimport { useTranslation } from 'react-i18next';\n\nfunction Welcome({ name }) {\n  const { t: $t } = useTranslation();\n  \n  return (\n    \u003cdiv\u003e\n      \u003ch1\u003e{$t(\"huan_ying_shi_yong_wo_men_de_xi_tong\")}\u003c/h1\u003e\n      \u003cp\u003e{$t(\"yong_hu\")}：{name}，{$t(\"nin_hao\")}！\u003c/p\u003e\n      \u003cbutton onClick={handleClick}\u003e{$t(\"dian_ji_kai_shi\")}\u003c/button\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n### Generated Internationalization File\n\n`locales/zh-CN.json`:\n```json\n{\n  \"huan_ying_shi_yong_wo_men_de_xi_tong\": \"欢迎使用我们的系统\",\n  \"yong_hu\": \"用户\",\n  \"nin_hao\": \"您好\",\n  \"dian_ji_kai_shi\": \"点击开始\"\n}\n```\n\n## 📝 License\n\nISC\n\n## 🤝 Contributing\n\nIssues and Pull Requests are welcome!\n\n---\n\nFor more detailed configuration and advanced features, please check the [documentation](./docs/). ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2ue%2Fi18n-x","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F2ue%2Fi18n-x","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2ue%2Fi18n-x/lists"}