intlify / vue-i18n-loader

:globe_with_meridians: vue-i18n loader for custom blocks
MIT License
267 stars 29 forks source link

Not translate from tag <i18n> #137

Closed major697 closed 3 years ago

major697 commented 3 years ago
Vue ver: 2.6.12
vue-i18n ver: 8.22.2
intlify/vue-i18n-loader ver: 1.0.0

I added to vue.config.js configuration:

chainWebpack: config => {
config.module
    .rule('i18n')
    .resourceQuery(/blockType=i18n/)
    .type('javascript/auto')
    .use('i18n')
    .loader('@intlify/vue-i18n-loader')
}

Next I added to main.js library vue-i18n:

import VueI18n from 'vue-i18n'
import { languages } from '@/locales'
Vue.use(VueI18n)

const i18n = new VueI18n({
    locale: 'en',
    fallbackLocale: 'en',
    silentTranslationWarn: true,
    messages: Object.assign(languages),
})

new Vue({
    el: '#app',
    i18n,
    components: {
        App,
    },
    template: '<App/>',
})

I have too languages object with translation word:

{
  "hi": "hi translate...",
}

Next I added to my component word to translate:

<template>
    <div>
        <div>{{ $t('hi') }}</div>
        <div>{{ $t('hello') }}</div>
    </div>    
</template>

<i18n>
{
  "en": {
      "hello": "hello translate..."
  },
}
</i18n>

When I trying translate word 'hi' everything work correctly, but when I try translate word 'hello' then nothing isn't translated

When I check language in component I get en:

created() {
    console.log(this.$i18n.locale) // en
},

Not working translate from tag <i18n>

kazupon commented 3 years ago

Thank you for your reporting! Unfortunataly, I could not reproduce. Could you provide minimum reproducion code please?

Alymbek commented 3 years ago

try to use legacy: true in const i18n = new VueI18n({})

kazupon commented 3 years ago

close due to in-activity