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

Using vue-i18n-loader with separate yaml files does not work when upgrading to 6.6.0 #703

Closed
1 of 2 tasks
coin-au-carre opened this issue May 9, 2020 · 2 comments
Closed
1 of 2 tasks
Labels

Comments

@coin-au-carre
Copy link

coin-au-carre commented May 9, 2020

Version

nuxt-i18n: Starting from 6.6.0
nuxt: ^2.0.0

Nuxt configuration

  • universal
  • spa

Nuxt-i18n configuration

i18n: {
      strategy: 'prefix_and_default', // default is prefix_except_default
      locales: [
        {
          code: 'fr',
          iso: 'fr-FR',
          name: 'Français'
        },
        {
          code: 'en',
          iso: 'en-US',
          name: 'English'
        }
      ],
      detectBrowserLanguage: {
        useCookie: true,
        cookieKey: 'i18n_redirected'
      },
      vueI18nLoader: true,
      // locales: ['en', 'fr'],
      defaultLocale: 'fr',
      vueI18n: {
        fallbackLocale: 'fr',
        silentFallbackWarn: true,
        messages: {
          fr: {
            language: 'Français'
          },
          en: {
            language: 'English'
          }
        }
      },
    },
// [...]
 extend(config, ctx) {
        config.module.rules.push({
          resourceQuery: /blockType=i18n/,
          type: 'javascript/auto',
          loader: ['@kazupon/vue-i18n-loader', 'yaml-loader']
        })
}

Steps to reproduce

Updating from nuxt-i18n 6.5.0 to 6.6.0 and later versions bring the following error.
We use separate YAML files <i18n src="./anypage.yaml"></i18n> in vue pages.
It was working fine in 6.5.0.

Error with yarn dev

 ERROR  Failed to compile with 1 errors                                                                                                                                                       friendly-errors 12:03:41

This relative module was not found:                                                                                                                                                           friendly-errors 12:03:41
                                                                                                                                                                                              friendly-errors 12:03:41
* ./_id.yaml?vue&type=custom&index=0&blockType=i18n&issuerPath=E%3A%5CMySite%5CmySite%5Cpages%5Cblog%5C_id.vue in ./pages/blog/_id.vue

Error with yarn build

ERROR in ./pages/redirect.vue                                                                        
Module not found: Error: Can't resolve '@kazupon/vue-i18n-loader' in 'E:\Mysite'              
 @ ./pages/redirect.vue 21:0-132 22:11-17 22:34-40                                                   
 @ ./.nuxt/router.js                                                                                 
 @ ./.nuxt/index.js                                                                                  
 @ ./.nuxt/client.js                                                                                 
 @ multi ./.nuxt/client.js                                                                           
                                                                                                     
ERROR in ./pages/payment.vue                                                                         
Module not found: Error: Can't resolve '@kazupon/vue-i18n-loader' in 'E:\Mysite'              
 @ ./pages/payment.vue 21:0-130 22:11-17 22:34-40                                                    
 @ ./.nuxt/router.js                                                                                 
 @ ./.nuxt/index.js                                                                                  
 @ ./.nuxt/client.js                                                                                 
 @ multi ./.nuxt/client.js                                                                           
                                                                                                     
ERROR in ./pages/app/catalog.vue                                                                     
Module not found: Error: Can't resolve '@kazupon/vue-i18n-loader' in 'E:\Mysite'              
 @ ./pages/app/catalog.vue 22:0-136 23:11-17 23:34-40                                                
 @ ./.nuxt/router.js                                                                                 
 @ ./.nuxt/index.js                                                                                  
 @ ./.nuxt/client.js                                                                                 
 @ multi ./.nuxt/client.js                                                                           

[etc]
@coin-au-carre
Copy link
Author

It looks like that changing to @intlify/vue-i18n-loader solved this issue :

        config.module.rules.push({
          resourceQuery: /blockType=i18n/,
          type: 'javascript/auto',
          loader: ['@intlify/vue-i18n-loader', 'yaml-loader']
        })

@rchl
Copy link
Collaborator

rchl commented May 10, 2020

That's indeed the right thing to do but also see this comment #578 (comment)

Basically you shouldn't need to customize this loader if all you are changing is adding yaml support. That is enabled by default.

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

No branches or pull requests

2 participants