vue-i18n icon indicating copy to clipboard operation
vue-i18n copied to clipboard

fall back locale

Open mvalitov opened this issue 2 years ago • 4 comments

I installed the package following the documentation in main.ts:

import VueI18n from 'vue-i18n'
Vue.use(VueI18n)

put the file with translation messages.ts:

export const messages = {
  en: {
    error: {
      required: '{field} is required',
      minLength: '{field} must be more than {length} characters',
      email: '{field} must be valid',
      alpha: '{field} must be only alphabet characters',
      sameAs: '{field} must be the same as {name}',
      accepted: '{field} must be accepted',
      empty: 'This field must not be empty'
    }
  }
}

and in my component i write:

import { messages } from '@/i18n/messages'

export default Vue.extend({
....
i18n: {
    messages
  },
....

I display messages in my component like this: <span class="error p-2" v-if="!$v.password_new.value.required && $v.password_new.$dirty">{{ $t('error.empty') }}</span>

everything works, but I constantly see messages in the console: [vue-i18n] Fall back to translate the keypath 'error.empty' with 'en' locale.

how can i set fall back locale in such case?

mvalitov avatar Dec 07 '21 15:12 mvalitov

I am experiencing the same error

themegaphoenix avatar Dec 20 '21 20:12 themegaphoenix

I have the same issue, i lazy-load the modules in and get overloaded with these messages. image But still my files are getting in loaded correctly. image image

ClumsyPenguin avatar Apr 06 '22 13:04 ClumsyPenguin

@mvalitov i think you can use a fallbackLocale option when you create it.

const i18n = setupI18n({
  legacy: false,
  locale: "en",
  fallbackLocale: "en",
  messages,
  silentTranslationWarn: true,
});

ClumsyPenguin avatar Apr 06 '22 14:04 ClumsyPenguin

I get the same warning messages even with the fallbackLocale.

sebastian-raubach avatar Apr 19 '22 18:04 sebastian-raubach