国际化网站
- 作者仓库星标 0
- 作者仓库 skills-registry
- 领域
- 工程开发
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @tomevault-io · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 即装即用
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- macOS · Linux · Windows
- 运行环境要求
- Node.js
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 网络行为
- 允许外网请求
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
第1步:准备基础语言文件
确保英语 (`en.json`) 文件作为模板存在: 所需目录: `i18n/messages/en.json` - 主要翻译 `i18n/pages/landing/en.json` - 着陆页翻译 验证结构:
第 2 步:添加新的语言文件
运行语言添加脚本: 该脚本的作用: 将 `en.json` 复制到所有目标语言文件 使用新语言环境更新 `i18n/locale.ts` 使用语言映射更新 `i18n/request.ts`
步骤 3:验证配置更新
检查`i18n/locale.ts`:检查`i18n/request.ts`:已配置语言代码映射`zh-CN`→`zh`、`zh-HK`→`zh-hk`映射检查`public/sitemap.xml`:
第 4 步:添加翻译
选项 A:使用 AI 翻译(更快,但需要审核):在脚本的 `translations` 对象中配置翻译。选项 B:手动翻译(建议质量):使用正确的翻译编辑每个语言文件:翻译最佳实践:
第 5 步:配置 SEO 元素
hreflang 标签 - 通过站点地图自动进行,但需要验证:请参阅 reference/hreflang-guide.md 以获取完整指南。本地化元标记 - 在每种语言文件中进行翻译:URL 结构 - 验证格式是否正确:英语:`https://example.com/` 或 `https://example.com/en/`
第 6 步:验证和测试
构建项目: 关键:在继续之前修复所有错误。手动测试:语言切换器:访问各个语言版本
# Internationalizing Websites
Complete workflow for adding multi-language support to Next.js websites with SEO best practices.
## When to use this Skill
- Adding new language versions to existing website
- Setting up i18n (internationalization) for new website
- Configuring SEO for multiple languages
- User mentions: "add language", "translation", "localization", "hreflang", "multi-language"
## Supported Languages
Common target markets:
- 🇺🇸 English (en) - Global market
- 🇯🇵 Japanese (ja) - Asian market
- 🇨🇳 Chinese (zh) - Chinese market
Extended support available for:
- Korean (ko), Portuguese (pt), Spanish (es), French (fr), German (de)
- Arabic (ar), Vietnamese (vi), Hindi (hi), Indonesian (id), Thai (th)
- Traditional Chinese (zh-hk), Italian (it), Russian (ru)
## Internationalization Workflow
Copy this checklist and track your progress:
```
i18n Progress:
- [ ] Step 1: Prepare base language files
- [ ] Step 2: Add new language files
- [ ] Step 3: Update configuration files
- [ ] Step 4: Add translations
- [ ] Step 5: Configure SEO elements
- [ ] Step 6: Validate and test
```
### Step 1: Prepare base language files
Ensure English (`en.json`) files exist as templates:
**Required directories**:
- `i18n/messages/en.json` - Main translations
- `i18n/pages/landing/en.json` - Landing page translations
**Verify structure**:
```bash
# Check if base files exist
ls i18n/messages/en.json
ls i18n/pages/landing/en.json
```
If missing, create them with complete translation keys for your website.
### Step 2: Add new language files
Run the language addition script:
```bash
node scripts/i18n-add-languages.mjs
```
**What this script does**:
- Copies `en.json` to all target language files
- Updates `i18n/locale.ts` with new locales
- Updates `i18n/request.ts` with language mappings
- Updates `public/sitemap.xml` with new language URLs
**Script configuration** (in `i18n-add-languages.mjs`):
- `languages` array - List of languages to add
- `languageNames` object - Language display names
- `targetDirs` array - Directories containing translation files
See [WORKFLOW.md](WORKFLOW.md) for detailed step-by-step guide.
### Step 3: Verify configuration updates
**Check `i18n/locale.ts`**:
```typescript
export const locales = ["en", "ja", "zh", "ko", ...];
export const localeNames: any = {
en: "English",
ja: "日本語",
zh: "中文",
ko: "한국어",
...
};
```
**Check `i18n/request.ts`**:
- Language code mappings configured
- `zh-CN` → `zh`, `zh-HK` → `zh-hk` mappings present
**Check `public/sitemap.xml`**:
- All language versions listed
- `hreflang` tags present for each URL
### Step 4: Add translations
**Option A: Using AI translation** (faster but needs review):
```bash
# Add structured data and pricing translations
node scripts/i18n-add-schema.js
```
Configure translations in the script's `translations` object.
**Option B: Manual translation** (recommended for quality):
Edit each language file with proper translations:
```bash
# Open language file
code i18n/messages/ja.json
```
**Translation best practices**:
- Use native speakers when possible
- Maintain SEO keywords in target language
- Adapt content to local culture, don't just translate
- Keep formatting consistent (placeholders, variables)
See [reference/locale-codes.md](reference/locale-codes.md) for language code reference.
### Step 5: Configure SEO elements
**hreflang tags** - Automatic via sitemap, but verify:
See [reference/hreflang-guide.md](reference/hreflang-guide.md) for complete guide.
**Localized meta tags** - Translate in each language file:
```json
{
"metadata": {
"title": "Your Site Title",
"description": "Your SEO description"
}
}
```
**URL structure** - Verify correct format:
- English: `https://example.com/` or `https://example.com/en/`
- Japanese: `https://example.com/ja/`
- Chinese: `https://example.com/zh/`
### Step 6: Validate and test
**Build the project**:
```bash
npm run build
```
**CRITICAL: Fix any errors before proceeding.**
**Manual testing**:
1. **Language switcher**:
- Visit each language version
- Verify language switcher shows all languages
- Click each language link, verify correct page loads
2. **Content display**:
- Check all pages render correctly in each language
- Verify no untranslated text (check for English in non-English pages)
- Test special characters display correctly (Japanese, Chinese, Arabic)
3. **SEO elements**:
- Inspect `<html lang="...">` attribute matches page language
- Verify `<link rel="alternate" hreflang="...">` tags present
- Check meta tags are in correct language
**Automated validation**:
```bash
# Check sitemap
curl https://your-site.com/sitemap.xml | grep hreflang
# Validate hreflang (use online tool)
# Google Search Console > Internationalization > hreflang
```
**SEO checklist** - See [reference/seo-checklist.md](reference/seo-checklist.md).
**If validation fails**:
- Review error messages carefully
- Check configuration files for typos
- Verify language codes are correct
- Return to Step 3 and fix issues
**Only proceed when all validations pass.**
## Important Notes
### Language Code Standards
Use ISO 639-1 (two-letter codes) with optional regional variants:
- `en` - English
- `ja` - Japanese
- `zh` - Simplified Chinese
- `zh-hk` - Traditional Chinese (Hong Kong)
- `pt` - Portuguese
- `pt-br` - Brazilian Portuguese
See [reference/locale-codes.md](reference/locale-codes.md) for complete list.
### SEO Implications
**Correct i18n improves SEO by**:
- Targeting users in their native language
- Avoiding duplicate content penalties
- Helping search engines serve correct language version
**Common SEO mistakes to avoid**:
- ❌ Auto-redirect based on IP (prevents search engines from crawling all versions)
- ❌ Missing hreflang tags (causes duplicate content issues)
- ❌ Inconsistent URL structure across languages
- ❌ Untranslated meta tags
### Translation Quality
**AI translation vs Human translation**:
- ✅ AI: Fast, cost-effective, good for initial draft
- ⚠️ AI: May miss cultural nuances, needs review
- ✅ Human: Better quality, cultural adaptation
- ⚠️ Human: Slower, more expensive
**Recommended approach**:
1. Use AI to generate initial translations
2. Have native speaker review and refine
3. Test with target market users
4. Iterate based on feedback
### Next.js i18n Routing
The system uses `next-intl` for routing:
- Automatic locale detection from URL
- Language switcher component
- Localized navigation
Configuration in `i18n/locale.ts` and `i18n/request.ts`.
## Post-Internationalization Tasks
After adding languages:
1. **Submit updated sitemap to Google Search Console**
2. **Create separate Search Console properties** for each language/region
3. **Monitor international organic traffic** in Analytics
4. **A/B test translations** if conversion rates differ by language
5. **Set up alerts** for international crawl errors
## Script Locations
All i18n scripts are in the `scripts/` directory:
- `i18n-add-languages.mjs` - Add new language files
- `i18n-add-schema.js` - Add structured data translations
## Reference Materials
- [WORKFLOW.md](WORKFLOW.md) - Detailed step-by-step workflow
- [reference/hreflang-guide.md](reference/hreflang-guide.md) - hreflang implementation guide
- [reference/locale-codes.md](reference/locale-codes.md) - Language codes reference
- [reference/seo-checklist.md](reference/seo-checklist.md) - International SEO checklist
For troubleshooting, see [WORKFLOW.md](WORKFLOW.md) troubleshooting section.
---
> Source: [ComeOnOliver/skillshub](https://github.com/ComeOnOliver/skillshub) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-22 -->
章节与文件索引
按说明文件中的顺序排列。
何时使用该技能
支持的语言
国际化工作流程
第1步:准备基础语言文件
第 2 步:添加新的语言文件
文件/命令 -> en.json · i18n/messages/en.json · i18n/pages/landing/en.json · i18n/locale.ts · i18n/request.ts · public/sitemap.xml · i18n-add-languages.mjs · languages
内容校验值 -> ac6b16b8e1ac
当前原文的自动摘译,尚未人工审校。
何时使用该技能
向现有网站添加新语言版本 为新网站设置 i18n(国际化) 为多种语言配置 SEO 用户提及:“添加语言”、“翻译”、“本地化”、“hreflang”、“多语言”
支持的语言
共同目标市场: 🇺🇸 英语 (en) - 全球市场 🇯🇵 日语 (ja) - 亚洲市场 🇨🇳 中文 (zh) - 中国市场 扩展支持可用于:
国际化工作流程
复制此清单并跟踪您的进度: