360 Secure SkillHub
360 安全技能中心

nuxt-i18n

该 Skill 指导检查 Nuxt 项目中的 @nuxtjs/i18n 版本与现有配置,按配置、消息和路由/SEO 查阅参考文档,并实现语言区域、翻译消息、本地化链接与语言切换器;最后运行准备命令、类型检查并在多个语言路由下验证。

onmax
热度 0.00
最近更新 2026-10-19 02:47:28
分类:开发依赖:代码执行 / 读写文件应用场景:代码生成 / 翻译

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add onmax/nuxt-skills/nuxt-i18n
Metadata
name
nuxt-i18n
description
Internationalize Nuxt applications with @nuxtjs/i18n. Use when configuring locales or browser detection, translating messages or routes, building locale switchers, handling fallbacks, lazy-loading messages, or adding locale SEO.
license
MIT

Nuxt I18n

Nuxt I18n owns locale messages, localized routes, language detection, and locale metadata. Nuxt owns the surrounding page, rendering, and server lifecycle.

Workflow

  1. Inspect the installed @nuxtjs/i18n version, nuxt.config.*, i18n/i18n.config.*, locale files, and affected pages. The setup is understood when locale codes, files, defaultLocale, and the routing strategy agree.
  2. Open the smallest matching guide below. Keep module options in nuxt.config, Vue I18n options in i18n.config, and translated messages in locale files.
  3. Implement with localized links and module composables so routing, message loading, and SEO share one locale state.
  4. Run nuxi prepare and the project's typecheck, then visit the affected route in the default and one secondary locale. The change is complete when both locales render the expected message, URL, language metadata, and fallback behavior.

Routing

Task Open
Installation, locale objects, file layout, browser detection, or Vue I18n config Configuration
Translation keys, interpolation, plurals, dates, numbers, or runtime message loading Messages
Route strategies, localized links, switchers, custom paths, dynamic slugs, or SEO Routing and SEO
Nuxt pages, middleware, data fetching, SSR state, or server routes nuxt skill

Baseline

npx nuxi@latest module add @nuxtjs/i18n
export default defineNuxtConfig({
  modules: ['@nuxtjs/i18n'],
  i18n: {
    defaultLocale: 'en',
    locales: [
      { code: 'en', language: 'en-US', name: 'English', file: 'en.json' },
      { code: 'fr', language: 'fr-FR', name: 'Français', file: 'fr.json' },
    ],
  },
})
{
  "welcome": "Welcome"
}

Locale files resolve from i18n/locales/ by default. Use the same locale code in configuration, route helpers, locale files, and fallback rules.