Skip to content

๐Ÿ”„ Migrating from nuxt-i18n to Nuxt I18n Micro โ€‹

Looking for the v2 โ†’ v3 upgrade guide?

See Upgrading from v2.x to v3.0.0.

Why Migrate? โ€‹

  • โšก Improved Performance: Up to 90% faster build times and 88% less memory
  • ๐Ÿ”ง Simplified Configuration: Streamlined setup with sensible defaults
  • ๐Ÿ“‰ Better Resource Management: Optimized handling of large translation files

Key Differences โ€‹

Featurenuxt-i18nNuxt I18n Micro
Translation filesJS/TS/JSON, loaded via vueI18nJSON only, auto-generated in dev
Route generationRuntimeBuild-time (@i18n-micro/route-strategy)
Translation loadingBundled into JSLazy-loaded JSON per page
Locale stateuseI18n() from vue-i18nuseI18nLocale() composable
detectBrowserLanguageSupportedUse autoDetectLanguage instead

Step-by-Step โ€‹

1. Install โ€‹

bash
npm install nuxt-i18n-micro

2. Update Configuration โ€‹

Before (nuxt-i18n):

typescript
export default defineNuxtConfig({
  modules: ['nuxt-i18n'],
  i18n: {
    locales: [
      { code: 'en', iso: 'en-US' },
      { code: 'fr', iso: 'fr-FR' },
    ],
    defaultLocale: 'en',
    vueI18n: './i18n.config.js',
    detectBrowserLanguage: { useCookie: true },
  },
})

After (Nuxt I18n Micro v3):

typescript
export default defineNuxtConfig({
  modules: ['nuxt-i18n-micro'],
  i18n: {
    locales: [
      { code: 'en', iso: 'en-US', dir: 'ltr' },
      { code: 'fr', iso: 'fr-FR', dir: 'ltr' },
    ],
    defaultLocale: 'en',
    translationDir: 'locales',
    meta: true,
    localeCookie: 'user-locale',
    autoDetectLanguage: true,
  },
})

3. Reorganize Translation Files โ€‹

Move translations to the locales directory in JSON format. Here is a full project comparison:

        • JSONDen.jsonall translations in one file
        • JSONDru.json
        • JSONDde.json
      • VUEindex.vue
      • VUEpage.vue
      • JSONtsconfig.json
    • TSMnuxt.config.tsconfig will change
    • JSONpackage.json

TIP

Missing page-specific translation files are auto-generated in development mode โ€” just run nuxt dev and the module will create empty JSON files for each page and locale.

4. Update Navigation โ€‹

diff
- <nuxt-link :to="{ name: 'index' }">Home</nuxt-link>
+ <NuxtLink :to="$localeRoute({ name: 'index' })">Home</NuxtLink>
+ <!-- or use the built-in component -->
+ <i18n-link :to="{ name: 'index' }">Home</i18n-link>

5. Update SEO โ€‹

Remove any manual SEO configurations from nuxt-i18n. Nuxt I18n Micro generates hreflang, canonical URLs, and Open Graph tags automatically when meta: true is set.

6. Test โ€‹

Thoroughly test translations, locale switching, redirects, and SEO meta tags.


๐Ÿ›ก๏ธ Common Issues and Troubleshooting โ€‹

โŒ Translation Files Not Loading โ€‹

Ensure translation files are in the correct directory and follow JSON format. Verify that translationDir matches your file location.

โš ๏ธ Route Not Found Errors โ€‹

Check that all locale codes in locales array are correct and that routes are properly set up.

๐Ÿท๏ธ Missing SEO Tags โ€‹

Verify that meta: true is set and each locale has a valid iso code.

๐Ÿ”„ Hydration Mismatches โ€‹

If using no_prefix strategy, set the locale in a server plugin with order: -10 using useI18nLocale().setLocale() to ensure server and client agree on the locale. See Custom Language Detection.

๐Ÿช Redirects Not Working โ€‹

For prefix strategies, ensure localeCookie: 'user-locale' is set. Without a cookie, the redirect plugin has no way to remember the user's preferred locale across page reloads.

Released under the MIT License.