Vue.js Developers

Helping web professionals up their skill and knowledge of Vue.js

Follow publication

VUE with TYPESCRIPT

Manage Vue i18n with Typescript

Internationalize your Vue project thanks to vue-i18n along with Typescript

Adrien Miquel
Vue.js Developers
Published in
4 min readMay 27, 2020

Your Vue project is running well for now. Greeeeat! 💥💥💥

All text is in English and it’s a good bet since you target all English speakers (a large part of the population). But it could be interesting to manage several languages to make your app world wide 🌐 and closer to your users 👩‍💻.

Photo by Aaron Burden on Unsplash

In this article, you will learn how to manipulate Vue i18n with Typescript. It’s a very handy and easy-to-use library to manage a multi-language app.

⚙ ️Setting things up

Installing vue-i18n starts with an npm command of course:

npm install vue-i18nyarn add vue-i18n #OR with yarnvue add i18n #OR with Vue CLI 3.x

Then in your main.ts file, you just need to add the following lines:

import Vue from 'vue'
import VueI18n from 'vue-i18n'

Vue.use(VueI18n)

For further details 🔍 about installation, I recommend you to read the doc:

Adding Typescript support

First, let’s create a file defining some typings in a dedicated folder named i18n:

Then JSON files have to be created to map the translations in an object:

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Vue.js Developers
Vue.js Developers

Published in Vue.js Developers

Helping web professionals up their skill and knowledge of Vue.js

Adrien Miquel
Adrien Miquel

Written by Adrien Miquel

Sr Frontend Engineer performing with Vue, TS/JS, GitLab | Writing articles monthly

Responses (1)

Write a response