I18n-module: nuxt-i18n does not generate a file named index.html for non default locales

Created on 7 Mar 2019  Â·  6Comments  Â·  Source: nuxt-community/i18n-module

Version

5.8.5

Reproduction link

N/A

Steps to reproduce

This is my nuxt-i18n config:

['nuxt-i18n', {
      locales: [
        { code: 'en', iso: 'en-US', name: 'English', file: 'en-US.js' },
        { code: 'ja', iso: 'ja', name: '日本人', file: 'ja.js' }
      ],
      defaultLocale: 'en',
      lazy: true,
      langDir: 'locale/',
      seo: false
    }]
  • run nuxt generate
  • look in the /dist folder under non-default locale
  • the file that should be index.html is called .html (no name for the file)

What is expected ?

nuxt-i18n needs to generate a file named index.html for each locale, just like it does for the default locale.

What is actually happening?

nuxt-i18n generates a file named .html and not index.html, which interferes with site hosting like Netlify which expect a file with that name.

Additional comments?

Is that the expected behavior or am I experiencing a bug?

This bug report is available on Nuxt community (#c211)
wontfix

All 6 comments

I currently solved the issue by running a small renaming script after running nuxt generate:

fix-index-locales.js

const nuxtConfig = require('../nuxt.config');
var fs = require('fs');

let nuxtI18nConfig = nuxtConfig.modules.find(m => m[0] === 'nuxt-i18n')[1];

nuxtI18nConfig.locales.filter(l => l.code !== nuxtI18nConfig.defaultLocale).forEach(locale => {
  fs.rename(`./dist/${locale.code}/.html`, `./dist/${locale.code}/index.html`, function (err) {
    if (err) console.log('ERROR: ' + err);
  });
});

package.json

"scripts": {
    "generate": "nuxt generate && node ./build-utils/fix-index-locales.js"
}

Hopefully it will help people who have the same issue..

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@OfekA I ran into the same problem, see https://github.com/nuxt-community/nuxt-i18n/issues/370

Why has this issue been labelled wontfix?

Duplicate of #370

(You didn't mention but I guess you have also used { generate: { subFolders: false } } since that is the prerequisite for the bug to trigger.)

(You didn't mention but I guess you have also used { generate: { subFolders: false } } since that is the prerequisite for the bug to trigger.)

Yup we use that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ebeloded picture ebeloded  Â·  15Comments

thariddler picture thariddler  Â·  23Comments

adetbekov picture adetbekov  Â·  21Comments

manniL picture manniL  Â·  24Comments

NadhirBoukhenifra picture NadhirBoukhenifra  Â·  30Comments