Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not work import modules in locales files after add hooks to core after latest package upgrade #835

Closed
1 of 2 tasks
altpoint opened this issue Aug 5, 2020 · 4 comments · Fixed by #836
Closed
1 of 2 tasks
Labels

Comments

@altpoint
Copy link

altpoint commented Aug 5, 2020

Version

nuxt-i18n: 6.13.6
nuxt: 2.14.1

Nuxt configuration

mode:

  • 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

  1. Create locales/en/index.js
  2. Create locales/en/actions.js like this:
export default {
  add: 'Add item',
  reset: 'Reset form',
  save: 'Save',
  create: 'Create item',
  saveDraft: 'Save draft',
}
  1. Import module from actions.js to index.js
  2. 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   
@thebrownfox
Copy link

Same here, but I use and import json.

@rchl
Copy link
Collaborator

rchl commented Aug 5, 2020

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

@rchl
Copy link
Collaborator

rchl commented Aug 5, 2020

Fix released in v6.13.7

@maximilianschmid
Copy link

Great. v6.13.7 fixes this issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants