s00d / nuxt-i18n-micro

Nuxt I18n Micro is a fast, simple, and lightweight internationalization (i18n) module for Nuxt
https://s00d.github.io/nuxt-i18n-micro/
MIT License
89 stars 12 forks source link

Error: Route paths should start with a "/": "\:locale(en-US|pt-PT)\home" should be "/\:locale(en-US|pt-PT)\home" #17

Closed SamuelFerreiraJimpisoft closed 1 month ago

SamuelFerreiraJimpisoft commented 1 month ago

Describe the bug Installed and configured everything like the docs state. I am not able, by any means, to make the app work. It always crashes. Only works without errors when i remove the locales array from the i18n configuration object (on file nuxt.config.ts)

Keep in mind i didn't do any extra configs or are in an advanced locale stages. Just decided to try this nuxt module and it didn't work with the initial setup.

The errors are always the same:

nuxt.js?v=1c8a7cd6:125 [nuxt] error caught during app initialization 
Error: Route paths should start with a "/": "\:locale(en-US|pt-PT)\home" should be "/\:locale(en-US|pt-PT)\home".
    at tokenizePath (vue-router.mjs?v=1c8a7cd6:783:11)
    at createRouteRecordMatcher (vue-router.mjs?v=1c8a7cd6:893:33)
    at addRoute (vue-router.mjs?v=1c8a7cd6:960:17)
    at vue-router.mjs?v=1c8a7cd6:1085:29
    at Array.forEach (<anonymous>)
    at createRouterMatcher (vue-router.mjs?v=1c8a7cd6:1085:10)
    at createRouter (vue-router.mjs?v=1c8a7cd6:2131:19)
    at setup (router.js?v=1c8a7cd6:41:20)
    at client.mjs:37:36
    at executeAsync (index.mjs?v=1c8a7cd6:111:19)
runtime-core.esm-bun….js?v=1c8a7cd6:3632 Hydration completed but contains mismatches
nuxt.js?v=1c8a7cd6:125 [nuxt] error caught during app initialization
TypeError: Cannot read properties of undefined (reading 'beforeEach')
    at setup (nuxt-root.vue:37:14)
    at callWithErrorHandling (runtime-core.esm-bundler.js?v=1c8a7cd6:200:19)
    at setupStatefulComponent (runtime-core.esm-bundler.js?v=1c8a7cd6:7707:25)
    at setupComponent (runtime-core.esm-bundler.js?v=1c8a7cd6:7668:36)
    at mountComponent (runtime-core.esm-bundler.js?v=1c8a7cd6:4884:7)
    at hydrateNode (runtime-core.esm-bundler.js?v=1c8a7cd6:3793:11)
    at hydrate (runtime-core.esm-bundler.js?v=1c8a7cd6:3667:5)
    at mount (runtime-core.esm-bundler.js?v=1c8a7cd6:2638:13)
    at app.mount (runtime-dom.esm-bundler.js?v=1c8a7cd6:1522:14)
    at initApp (entry.js:55:14)

To Reproduce

// package.json

"dependencies": {
      "@element-plus/nuxt": "^1.0.10",
      "nuxt": "^3.13.0",
      "nuxt-i18n-micro": "^1.17.0",
      "sass": "^1.77.8",
      "vue": "latest"
   },
   "devDependencies": {
      "@trivago/prettier-plugin-sort-imports": "^4.3.0",
      "prettier": "^3.3.3",
      "standard-version": "^9.5.0"
   }
// nuxt.config.ts

export default defineNuxtConfig({
   compatibilityDate: '2024-04-03',
   devtools: { enabled: true },
   i18n: {
      locales: [
         { code: 'en', iso: 'en-US', dir: 'ltr' },
         { code: 'pt', iso: 'pt-PT', dir: 'ltr' },
      ],
      defaultLocale: 'en',
      translationDir: 'locales',
      meta: true,
   },
   modules: ['@element-plus/nuxt', 'nuxt-i18n-micro'],
   elementPlus: {
      themes: ['dark'],
   },
});

Screenshots This is the folder structure: image

Desktop:

s00d commented 1 month ago

Hi there,

I’ve fixed the issue in version v1.18.1. I overlooked the fact that routes are not file paths and should use POSIX-compliant separators. Everything should work fine now.

SamuelFerreiraJimpisoft commented 1 month ago

I've tested the latest release and the reported issue has been fixed. Thank you very much 🙏