Questions tagged [vue-i18n]

Use when referencing the vue-i18n plugin for Vue.js

Internationalization plugin for Vue.js.

Github Documentation

567 questions
38
votes
10 answers

You are running the esm-bundler build of vue-i18n. It is recommended to configure your bundler to explicitly replace feature flag globals with

I have created an ionic app and added vue-i18n. npx ionic start myapp tabs --type vue npm install vue-i18n@next I did the very first step of the VueI18n setup and added this to "./src/main.ts": import { createI18n } from 'vue-i18n'; const i18n =…
jonas
  • 637
  • 1
  • 7
  • 9
28
votes
4 answers

Problem to use VueI18n outside a component

I'm trying to use i18n outside a component I've found this solution https://github.com/dkfbasel/vuex-i18n/issues/16 telling to use Vue.i18n.translate('str'), but when I call this occurs an error Cannot read property 'translate' of undefined. I'm…
Alexandre Heinen
  • 623
  • 1
  • 7
  • 19
25
votes
3 answers

VueI18n check if translation exists

Is there a way to check if translation exist?

{{ $t('some_key') }}

In this case if there is no translation it will print 'some_key'. Maybe there is a way to configure global fallback?
Dvdgld
  • 1,984
  • 2
  • 15
  • 41
22
votes
2 answers

vuejs default properties set from vue-i18n

I would like to set a default property from dictionary like this: props: { title: { type: String, default: this.$t("basic.confirm"), }, description: { type: String, } }, ... The $t is a vue-i18n, and I would…
LakiGeri
  • 2,046
  • 6
  • 30
  • 56
20
votes
6 answers

Push a route (Moving from vueJS to nuxtJS)

I am converting a VueJS project to Nuxt.js and I have a problem understanding how nuxt handles routing. Its documentation doesn't say anything about Pushing a route. Using VueJS I have the following in a component. //template
user9801251
16
votes
3 answers

Vue-i18n - Cannot read property 'config' of undefined

First of all I show you what works (in App.js) import router from './routes.js'; import VueI18n from 'vue-i18n'; const messages = { en: { message: { hello: 'hello world' } } } // Create VueI18n instance with options const i18n =…
Philipp Mochine
  • 4,351
  • 10
  • 36
  • 68
15
votes
7 answers

multiline text using vuejs i18n

I'm using i18n single file component to have translation support on my application. To do so, I'm using the tag as following { "fr": { "text": "blabla in french blabla bla" }, "en": { "text": "blabla…
user1595929
  • 1,284
  • 3
  • 13
  • 23
13
votes
1 answer

How to use Vue i18n translation in .js file?

I'm working on VueCLI. I've created .js file that contains rules for inputs: import Vue from 'vue' export const $t = (sign) => Vue.prototype.$t(sign) function checkMail(email) { const re =…
BobiDaHombre
  • 193
  • 1
  • 4
  • 19
12
votes
6 answers

Vue-i18n 'Cannot read property '_t' of undefined at Proxy.Vue.$t'

Having issues incorporating vue-i18n into my app. Used this page as inspiration. {{ $t('username') }}: {{ username…
minisaurus
  • 1,099
  • 4
  • 17
  • 30
12
votes
2 answers

Get current locale in a child component

I don't manage to get the locale parameter from vue-i18n in my child component. I've installed vue-i18n in cli ui. The translation with $t("message") is working but I have error when i try to access to i18n.locale my enter point (main.js) import…
Seb
  • 121
  • 1
  • 1
  • 4
11
votes
6 answers

How to mock/stub vue-i18n?

I have started to replace Jest with Vitest for my unit test library in my Vue 3 App. I am trying to write unit test for a component that uses the vue-i18n library to translate text within it but when I try to mount this component in my test file, it…
Mac
  • 1,025
  • 3
  • 12
  • 22
10
votes
2 answers

Jest error "SyntaxError: Need to install with `app.use` function" when using vue-i18n plugin for Vue3

I am using vue-i18n plugin for my Vue3(typescript) application. Below is my setup function in component code Home.vue import {useI18n} from 'vue-i18n' setup() { const {t} = useI18n() return { t } } Main.ts import { createI18n…
Purni
  • 297
  • 7
  • 19
10
votes
1 answer

WebStorm Vue-i18n, anyway to get editor autocompletion support?

I'm localizing a webapp using vue-i18n. Is there anyway to get WebStorm to recognize strings in a function prefixed with $t as a dot notation path reference? $t('messages.some.key') in my en.js file which looks like: exports defaults { messages:…
blak3r
  • 16,066
  • 16
  • 78
  • 98
9
votes
1 answer

vue-i18n - Detect 'unknown' type of token

When trying to interpolate values in my translation string using vue-i18n I keep getting this error: Detect 'unknown' type of token My messages.json looks as follows: { test: { "at_location": "At { name }" } } Usage:

{{…

Raymundus
  • 2,173
  • 1
  • 20
  • 35
9
votes
1 answer

Vue-i18n change locale not updating everything

i'm new to vue-i18n, seams great, but have some challenge getting it to work probably. All template translations are updated as expected when changing locale, but when script data() { return { locales: { en:…
pkdkk
  • 3,905
  • 8
  • 44
  • 69
1
2 3
37 38