Index of every page on this site: llms.txt
All skills
onmax avatar

/nuxt-i18n

@2e74504 official
by Maxonmax/nuxt-skills722 stars
38
Run it yourself

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.

Use this Skill: https://skilld.dev/gh/onmax/nuxt-skills/nuxt-i18n

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesconfiguration.md

≈881 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Configuration

Inspect the existing setup

Read the installed @nuxtjs/i18n version before choosing an API. Then inspect:

  • nuxt.config.* for module options, locales, routing, and detection
  • i18n/i18n.config.* for Vue I18n options such as fallback and formats
  • i18n/locales/ or the configured langDir for message resources
  • route and locale middleware that may already change the active locale

Keep locale codes as the shared identifiers across all four surfaces.

Define locale identity

export default defineNuxtConfig({
  modules: ['@nuxtjs/i18n'],
  i18n: {
    defaultLocale: 'en',
    strategy: 'prefix_except_default',
    locales: [
      {
        code: 'en',
        language: 'en-US',
        name: 'English',
        file: 'en.json',
        dir: 'ltr',
      },
      {
        code: 'ar',
        language: 'ar-EG',
        name: 'العربية',
        file: 'ar.json',
        dir: 'rtl',
      },
    ],
  },
})

Use:

  • code as the runtime and routing identifier
  • language as the BCP 47 tag for browser matching and SEO
  • name as the human-readable switcher label
  • file or files for locale resources
  • dir when the locale's writing direction differs from the default

Locale files resolve from i18n/locales/ by default. langDir is relative to the i18n/ restructure directory, so keep it relative.

Module options and Vue I18n options

Routing, locale files, browser detection, domains, and SEO base URLs belong in nuxt.config:

export default defineNuxtConfig({
  i18n: {
    defaultLocale: 'en',
    locales: [
      { code: 'en', language: 'en-US', file: 'en.json' },
      { code: 'fr', language: 'fr-FR', file: 'fr.json' },
    ],
  },
})

Fallbacks and number or date formats belong in i18n/i18n.config.ts:

export default defineI18nConfig(() => ({
  fallbackLocale: 'en',
}))

defaultLocale selects the default route locale. fallbackLocale selects messages when the active locale lacks a key; configure both deliberately.

Browser language detection

Use root-only detection for public, indexable sites so explicit locale URLs remain stable:

export default defineNuxtConfig({
  i18n: {
    detectBrowserLanguage: {
      useCookie: true,
      cookieKey: 'i18n_redirected',
      fallbackLocale: 'en',
      redirectOn: 'root',
    },
  },
})

Set detectBrowserLanguage: false when the application, account, domain, or upstream middleware owns locale selection. Preserve a user's explicit choice through setLocale() or localized navigation, and reserve detection for the entry points that need it.

Locale files and loading

Static locale files are lazy-loaded when they are listed with file or files:

export default defineNuxtConfig({
  i18n: {
    locales: [
      { code: 'en', files: ['en/common.json', 'en/app.json'] },
      { code: 'fr', files: ['fr/common.json', 'fr/app.json'] },
    ],
  },
})

Files load in array order, and later files override earlier keys. Put shared messages first and narrower overrides last.

Verification

Run npx nuxi prepare after changing module configuration, then run the project's typecheck. Start Nuxt and verify:

  • every configured locale file loads without warnings
  • the default locale matches the unprefixed route when using prefix_except_default
  • a missing secondary-locale key resolves through the intended fallback
  • browser detection redirects only on the configured paths
  • lang and dir reflect the active locale

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts1mo3 checks · Risk SAFE
  • Gen Agent Trust Hub1mo

    The skill provides comprehensive documentation and configuration examples for Nuxt applications using the @nuxtjs/i18n module. It describes standard workflows for internationalization, including loading translation messages from local files and remote APIs. A minor security consideration is the attack surface created by ingesting untrusted translation data from external sources.

  • Socket1mo

    No alerts

  • Snyk1mo

    Risk: LOW · No issues

Signed by skilld at 2e74504. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last week.

Activeupdated 4 months ago

README badge

README badge for onmax/nuxt-skills/nuxt-i18n