N/A
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
}]
nuxt generate/dist folder under non-default localeindex.html is called .html (no name for the file)nuxt-i18n needs to generate a file named index.html for each locale, just like it does for the default locale.
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.
Is that the expected behavior or am I experiencing a bug?
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.