Internationalizing Websites by zhanlincui/ultimate-agent-skills-collection
npx skills add https://github.com/zhanlincui/ultimate-agent-skills-collection --skill 'Internationalizing Websites'为 Next.js 网站添加多语言支持并遵循 SEO 最佳实践的完整工作流程。
常见目标市场:
可扩展支持:
复制此清单并跟踪您的进度:
i18n 进度:
- [ ] 步骤 1:准备基础语言文件
- [ ] 步骤 2:添加新语言文件
- [ ] 步骤 3:更新配置文件
- [ ] 步骤 4:添加翻译
- [ ] 步骤 5:配置 SEO 元素
- [ ] 步骤 6:验证和测试
确保英语 (en.json) 文件作为模板存在:
必需目录:
i18n/messages/en.json - 主要翻译广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
i18n/pages/landing/en.json - 着陆页翻译验证结构:
# 检查基础文件是否存在
ls i18n/messages/en.json
ls i18n/pages/landing/en.json
如果缺失,请为您的网站创建包含完整翻译键的文件。
运行语言添加脚本:
node scripts/i18n-add-languages.mjs
此脚本的作用:
en.json 复制到所有目标语言文件i18n/locale.tsi18n/request.tspublic/sitemap.xml脚本配置(在 i18n-add-languages.mjs 中):
languages 数组 - 要添加的语言列表languageNames 对象 - 语言显示名称targetDirs 数组 - 包含翻译文件的目录详细的分步指南请参见 WORKFLOW.md。
检查 i18n/locale.ts:
export const locales = ["en", "ja", "zh", "ko", ...];
export const localeNames: any = {
en: "English",
ja: "日本語",
zh: "中文",
ko: "한국어",
...
};
检查 i18n/request.ts:
zh-CN → zh、zh-HK → zh-hk 映射检查 public/sitemap.xml:
hreflang 标签选项 A:使用 AI 翻译(更快但需要审核):
# 添加结构化数据和定价翻译
node scripts/i18n-add-schema.js
在脚本的 translations 对象中配置翻译。
选项 B:手动翻译(推荐以确保质量):
使用适当的翻译编辑每个语言文件:
# 打开语言文件
code i18n/messages/ja.json
翻译最佳实践:
语言代码参考请参见 reference/locale-codes.md。
hreflang 标签 - 通过站点地图自动生成,但需验证:
完整指南请参见 reference/hreflang-guide.md。
本地化元标签 - 在每个语言文件中翻译:
{
"metadata": {
"title": "您的网站标题",
"description": "您的 SEO 描述"
}
}
URL 结构 - 验证格式是否正确:
https://example.com/ 或 https://example.com/en/https://example.com/ja/https://example.com/zh/构建项目:
npm run build
关键:在继续之前修复所有错误。
手动测试:
语言切换器:
内容显示:
SEO 元素:
<html lang="..."> 属性是否与页面语言匹配<link rel="alternate" hreflang="..."> 标签是否存在自动验证:
# 检查站点地图
curl https://your-site.com/sitemap.xml | grep hreflang
# 验证 hreflang(使用在线工具)
# Google Search Console > 国际化 > hreflang
SEO 清单 - 请参见 reference/seo-checklist.md。
如果验证失败:
仅在所有验证通过后才能继续。
使用 ISO 639-1(双字母代码)和可选的区域变体:
en - 英语ja - 日语zh - 简体中文zh-hk - 繁体中文(香港)pt - 葡萄牙语pt-br - 巴西葡萄牙语完整列表请参见 reference/locale-codes.md。
正确的 i18n 通过以下方式改善 SEO:
需要避免的常见 SEO 错误:
AI 翻译 vs 人工翻译:
推荐方法:
该系统使用 next-intl 进行路由:
配置位于 i18n/locale.ts 和 i18n/request.ts 中。
添加语言后:
所有 i18n 脚本都位于 scripts/ 目录中:
i18n-add-languages.mjs - 添加新语言文件i18n-add-schema.js - 添加结构化数据翻译故障排除请参见 WORKFLOW.md 的故障排除部分。
每周安装次数
–
代码仓库
GitHub 星标数
112
首次出现时间
–
安全审计
Complete workflow for adding multi-language support to Next.js websites with SEO best practices.
Common target markets:
Extended support available for:
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
Ensure English (en.json) files exist as templates:
Required directories :
i18n/messages/en.json - Main translationsi18n/pages/landing/en.json - Landing page translationsVerify structure :
# 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.
Run the language addition script:
node scripts/i18n-add-languages.mjs
What this script does :
en.json to all target language filesi18n/locale.ts with new localesi18n/request.ts with language mappingspublic/sitemap.xml with new language URLsScript configuration (in i18n-add-languages.mjs):
languages array - List of languages to addlanguageNames object - Language display namestargetDirs array - Directories containing translation filesSee WORKFLOW.md for detailed step-by-step guide.
Checki18n/locale.ts:
export const locales = ["en", "ja", "zh", "ko", ...];
export const localeNames: any = {
en: "English",
ja: "日本語",
zh: "中文",
ko: "한국어",
...
};
Checki18n/request.ts:
zh-CN → zh, zh-HK → zh-hk mappings presentCheckpublic/sitemap.xml:
hreflang tags present for each URLOption A: Using AI translation (faster but needs review):
# 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:
# Open language file
code i18n/messages/ja.json
Translation best practices :
See reference/locale-codes.md for language code reference.
hreflang tags - Automatic via sitemap, but verify:
See reference/hreflang-guide.md for complete guide.
Localized meta tags - Translate in each language file:
{
"metadata": {
"title": "Your Site Title",
"description": "Your SEO description"
}
}
URL structure - Verify correct format:
https://example.com/ or https://example.com/en/https://example.com/ja/https://example.com/zh/Build the project :
npm run build
CRITICAL: Fix any errors before proceeding.
Manual testing :
Language switcher :
Content display :
SEO elements :
<html lang="..."> attribute matches page language<link rel="alternate" hreflang="..."> tags presentAutomated validation :
# 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.
If validation fails :
Only proceed when all validations pass.
Use ISO 639-1 (two-letter codes) with optional regional variants:
en - Englishja - Japanesezh - Simplified Chinesezh-hk - Traditional Chinese (Hong Kong)pt - Portuguesept-br - Brazilian PortugueseSee reference/locale-codes.md for complete list.
Correct i18n improves SEO by :
Common SEO mistakes to avoid :
AI translation vs Human translation :
Recommended approach :
The system uses next-intl for routing:
Configuration in i18n/locale.ts and i18n/request.ts.
After adding languages:
All i18n scripts are in the scripts/ directory:
i18n-add-languages.mjs - Add new language filesi18n-add-schema.js - Add structured data translationsFor troubleshooting, see WORKFLOW.md troubleshooting section.
Weekly Installs
–
Repository
GitHub Stars
112
First Seen
–
Security Audits
Schema标记专家指南:结构化数据实现与SEO优化,提升富媒体搜索结果
28,500 周安装