English | 简体中文
Please note that the Node version installed on your local machine needs to be
>=16.
npm install tdesign-starter-cli -g# project initialization
td-starter init
# fill project name and description
? 请输入项目名称: [project-name]
? 请输入项目描述: Base on tdesign-starter-cli
...
cd [project-name]
# install dependencies
npm install
# run dev
npm run dev
# project initialization
td-starter init [project name] [root]
cd [project-name]
# install dependencies
npm install
# run dev
npm run dev
td-starter init tdesign-vue3-farm --type vue3 --buildToolType farmtd-starter init tdesign-vue3-farm -type vue3 -bt farm| Option | Description |
|---|---|
| -d, --description <description> | description of a project (default: "Base on tdesign-starter-cli") |
| -type, --type <type> | Code version vue2 | vue3 | react | miniProgram | mobileVue (default: "vue2") |
| -temp, --template <template> | Project template type: lite | all (default: "lite") |
| -bt, --buildToolType <buildToolType> | The construction tool for lite: vite | webpack (default: "vite") |
| -h, --help | display help for command |
The i18n command helps you convert Vue3 projects with i18n implementations to localized versions (removing i18n dependencies).
# Start the i18n localization process
td-starter i18n
# Then input the target project path when prompted
? 请输入目标项目路径: ./my-project# Specify the target project path directly
td-starter i18n --target ./my-project
# Short option
td-starter i18n -t ./my-project- Project Type: Currently only supports Vue3 projects with i18n setup
- Project Structure: Your project must have the following directory structure:
src/ └── locales/ └── lang/ ├── zh_CN.json (or other language codes) ├── en_US.json └── ...
The i18n command performs the following operations:
-
Project Analysis: Automatically detects if the project is a Vue3 project with i18n configuration
-
Language Detection: Scans the
src/locales/langdirectory to find all available language files -
Language Selection: Prompts you to choose a target language for localization
-
File Processing: Replaces all i18n function calls with static strings:
this.$t('key')→'translated_value'$t('key')→'translated_value't('key')→'translated_value'
-
Result Summary: Shows statistics including:
- Number of files processed
- Number of translation replacements made
The following language code formats are automatically recognized:
| Language Code | Language Name |
|---|---|
| zh_CN | 简体中文 |
| zh_TW | 繁體中文 |
| en_US | English |
| en | English |
| zh | 中文 |
| ja | 日本語 |
| ko | 한국어 |
| fr | Français |
| de | Deutsch |
| es | Español |
| ru | Русский |
# Step 1: Navigate to where tdesign-starter-cli is installed
td-starter i18n
# Step 2: Input project path
? 请输入目标项目路径: /Users/username/my-vue3-project
# Step 3: System detects project type
🔍 目标项目路径: /Users/username/my-vue3-project
✅ 检测到项目类型: vue3
# Step 4: System scans language configurations
🌍 可用语言:
- 简体中文 (zh_CN)
- English (en_US)
# Step 5: Select target language
? 请选择要本地化的目标语言: (Use arrow keys to select)
❯ 简体中文 (zh_CN)
English (en_US)
# Step 6: Process completed
✅ 本地化完成!
处理文件: 25 个
替换条目: 156 个- The i18n configuration files and import statements are still preserved
- Manual cleanup may be required if you want to completely remove i18n dependencies
- Test your application to ensure all translations are correctly replaced
- Keep your language configuration files for reference
| Issue | Solution |
|---|---|
| "无法识别项目类型" | Ensure your project has package.json with Vue 3 dependencies in the correct location |
| "未检测到语言配置" | Verify the src/locales/lang directory exists and contains .json language files |
| "未找到翻译: key.name" | The translation key is missing in the selected language file |
| No files processed | Check if there are .vue, .ts, or .js files in the src directory |
Use the following methods to check if the replacement was successful:
# Check if there are still i18n function calls
grep -r "\$t(" src/ --include="*.vue" --include="*.ts" --include="*.js"
# Check if there are still i18n imports
grep -r "vue-i18n" src/ --include="*.ts" --include="*.js"After replacement, to completely remove i18n, you can execute:
# 1. Remove i18n configuration files
rm -rf src/locales/
# 2. Remove dependencies from package.json
npm uninstall vue-i18n
# 3. Update import statements (manually or via script)
# Delete import { createI18n } from 'vue-i18n'
# Delete other i18n related importsThe MIT License. Please see the license file for more information.