I18n-module: [Bug Report] Breaks when you have extendRoutes defined

Created on 22 Mar 2018  路  6Comments  路  Source: nuxt-community/i18n-module

First of all great plugin! I found a bug when you define extendRoutes (https://nuxtjs.org/api/configuration-router/#extendroutes) the Nuxt app breaks because of the module. The error it returns in the terminal is as follow:

TypeError: Cannot read property 'replace' of undefined

  - routes.js:42 locales.forEach
    [secrid-nuxt]/[nuxt-i18n]/lib/routes.js:42:40

  - Array.forEach

  - routes.js:39 localizedRoutes.forEach.baseRoute
    [secrid-nuxt]/[nuxt-i18n]/lib/routes.js:39:13

  - Array.forEach

  - routes.js:38 generateRoutes
    [secrid-nuxt]/[nuxt-i18n]/lib/routes.js:38:19

  - module.js:23 Object.extendRoutes
    [secrid-nuxt]/[nuxt-i18n]/lib/module.js:23:23

  - utils.js:119 Object.extendRoutes
    [secrid-nuxt]/[nuxt]/lib/common/utils.js:119:23

  - builder.js:347 Builder.generateRoutesAndFiles
    [secrid-nuxt]/[nuxt]/lib/builder/builder.js:347:50

I created a gist with my Nuxt config: https://gist.github.com/martinrisseeuw/e1ffea12757710c4ff94ef1d95f5cf4b

Do you maybe have a solution or workaround that I can use the module?

This question is available on Nuxt.js community (#c25)

All 6 comments

Hi @martinrisseeuw, thanks for reporting this! This issue should be fixed in v2.9.1, hope you can give it a try!

@paulgv Great it works. Thanks a lot!

@paulgv I have updated the library to 4.0.1 because I wanted to have the custom routes functionality within page components. Unfortunately it looks like that this fix is broken? It seems that extendRoutes in my nuxt.config are ignored. Have you experienced this issue before and have a solution for it? If not I can go back to v2.9.1 and add the routing in the module settings.

I can confirm that this is broken on v4.1.0. I receive the error:

[1]   TypeError: Cannot read property 'replace' of undefined
[1]
[1]   - utils.js:38 getPageOptions
[1]     [nuxt-test]/[nuxt-i18n]/src/helpers/utils.js:38:37
[1]
[1]   - routes.js:28 buildLocalizedRoutes
[1]     [nuxt-test]/[nuxt-i18n]/src/helpers/routes.js:28:21
[1]
[1]   - routes.js:105 makeRoutes
[1]     [nuxt-test]/[nuxt-i18n]/src/helpers/routes.js:105:46
[1]
[1]   - module.js:60 Object.extendRoutes
[1]     [nuxt-test]/[nuxt-i18n]/src/module.js:60:29
[1]
[1]   - utils.js:119 Object.extendRoutes
[1]     [nuxt-test]/[nuxt]/lib/common/utils.js:119:23
[1]
[1]   - builder.js:347 Builder.generateRoutesAndFiles
[1]     [nuxt-test]/[nuxt]/lib/builder/builder.js:347:50

Hi guys, sorry about that, looks like the original fix was lost at some point. I re-applied it and released it in version v5.0.1

This bug-report has been fixed by @paulgv in release v5.0.1.

Was this page helpful?
0 / 5 - 0 ratings