question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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?

<div align="right">This bug report is available on Nuxt community (#c211)</div>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

3reactions
OfekAcommented, Mar 11, 2019

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…

0reactions
OfekAcommented, Sep 5, 2019

(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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

nuxt-i18n does not generate a file named index.html for ...
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...
Read more >
Nuxt generate don't generate route html file
In my case I have blog1 folder, inside index.vue file and all article.vue file, I used child route cause in this way I...
Read more >
A Guide to Localizing with Nuxt.js
In this tutorial, we'll use a library called nuxt-i18n , based on vue-i18n , with some Nuxt-specific localization options.
Read more >
API references | Vue I18n
The handler gets called with the localization target locale, localization path key, the Vue instance and values. If missing handler is assigned, ...
Read more >
A simple multi-language site with Nuxt.js and nuxt-i18n
In this article, we will see how to create a simple multilanguage website using Nuxt.js and nuxt-i18n module. In this case, we have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found