I18n-module: Not work import modules in locales files after add hooks to core after latest package upgrade

Created on 5 Aug 2020  路  4Comments  路  Source: nuxt-community/i18n-module

Version

nuxt-i18n: 6.13.6
nuxt: 2.14.1

Nuxt configuration

mode:

  • [x] universal
  • [ ] spa

Nuxt-i18n configuration

[
      'nuxt-i18n', {
        strategy: 'prefix_except_default',
        locales: [
          {
            code: 'ru',
            file: 'ru/index.js',
            name: 'RU',
            iso: 'ru-RU'
          },
          {
            code: 'en',
            file: 'en/index.js',
            iso: 'en-US',
            name: 'EN'
          }
        ],
        defaultLocale: 'en',
        vueI18n: {
          fallbackLocale: 'en'
        },
        lazy: true,
        langDir: 'locales/',
        vuex: {
          moduleName: 'i18n'
        }
      }]

Steps to reproduce

0) Create locales/en/index.js
1) Create locales/en/actions.js like this:

export default {
  add: 'Add item',
  reset: 'Reset form',
  save: 'Save',
  create: 'Create item',
  saveDraft: 'Save draft',
}

2) Import module from actions.js to index.js
3) Export from locales/en/index.js like this

import actions from './actions'
export default () => {
  return new Promise(function (resolve) {
    resolve({
        actions
    })
  })
}

What is Expected?

It should work as before

What is actually happening?

These relative modules were not found:                                                                                                                                                                                                         friendly-errors 18:10:35                                                                                                                                                                                                                                               friendly-errors 18:10:35
* ./actions in ./.nuxt/nuxt-i18n/default-lang/en/index.js   
bug 馃悰

Most helpful comment

Fix released in v6.13.7

All 4 comments

Same here, but I use and import json.

Hmm... that one is tricky.

Previously everything from langDir (including imported stuff) would end up in their own bundles. So I think that was not ideal.

The new approach requires that we copy individual files so that we can separate the file for default locale and other locales so that we can include default locale in the main bundle.

@thefoxie You can point locale's file to JSON file directly (unless you are doing something more than just importing that one file).

Fix released in v6.13.7

Great. v6.13.7 fixes this issue for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thariddler picture thariddler  路  23Comments

alexgrozav picture alexgrozav  路  21Comments

varna picture varna  路  14Comments

vodnicearv picture vodnicearv  路  20Comments

pi0 picture pi0  路  18Comments