I18n-module: pages are not correctly created using nuxt generate with subFolders = false

Created on 20 Jul 2019  路  5Comments  路  Source: nuxt-community/i18n-module

Version

6.0.0

Reproduction link

https://github.com/miteyema/nuxt-i18n-demo

Steps to reproduce

  • configure nuxt generate in nuxt.config.js with subFolders: false
  • npm/yarn run generate

What is expected ?

dist folder contains

  • index.html (home page in default locale)
  • nl.html (home page in other locale)
  • fr.html (home page in other locale)

What is actually happening?

dist folder contains

  • index.html
  • nl/.html (empty file name in locale folder)
  • fr/.html (empty file name in locale folder)

Additional comments?

Example is live on https://nuxt-i18n-demo.netlify.com
When you go directly to https://nuxt-i18n-demo.netlify.com/nl, it will give you an 404 error because the page was not correctly generated.

Why does nuxt generate create a .html with no file name inside the locale folder?

Screenshot 2019-07-23 at 11.28.28.png

This bug report is available on Nuxt community (#c262)

All 5 comments

This seems like a nuxt bug that triggers if route in router.js is generated with trailing slash:

{
  path: "/nl/",
  component: _2b36cd8f,
  name: "index___nl"
}

@manniL I believe this will also trigger with the newly added (or to-be added) trailingSlash option. Could you maybe move this issue to nuxt repo?

(btw. this can (I believe) be fixed in this module by not including trailing slashes, but it's still a nuxt bug)

Can't move it because it's not the same org :see_no_evil:
But that's right!

@rchl @manniL Thank you so much for looking into this problem!

I was going to workaround this in the module, but I'm having troubles testing it as typical node servers will do wrong thing in case like when having such directory structure:

  | fr/about.html
  | fr.html

If user requests /fr then the expected result is to serve fr.html while servers will generally try to serve fr/ directory and either return an index of files or fr/index.html content, if available or 404.

So I wonder if you are using some more sophisticated server that allows for configuring that behavior or you just happen to not have such directory structure?

@rchl I have incorporated the fix that is present in Nuxt v2.10.1 and have now indeed the directory structure you are mentioning.

I use Netlify, so if you try to go to example.com/fr/ of my website, Netlify will first convert it to example.com/fr as per their trailing slash documentation. As there exists a fr.html in the root directory, the French index page will be shown correctly, meaning no 404 (even-though you manually entered a URL with trailing slash that should give an error as there is no fr/index.html).

Maybe you could enlighten me with your server environment or problem, so I better understand what you mean?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jonalxh picture jonalxh  路  15Comments

albanm picture albanm  路  20Comments

javialon26 picture javialon26  路  20Comments

koteezy picture koteezy  路  16Comments

johnboylesingfield picture johnboylesingfield  路  17Comments