vue-i18n
vue-i18n copied to clipboard
fall back locale
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?
I am experiencing the same error
I have the same issue, i lazy-load the modules in and get overloaded with these messages.
But still my files are getting in loaded correctly.
@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,
});
I get the same warning messages even with the fallbackLocale
.