Vue Localization with Vue I18n

In this guide, we’ll show you how you can easily localize your Vue.js application using Vue I18n with the help of Translized.

29 May, 2022

8 min read

Initial Setup

Vue I18n is a popular internationalization plugin for Vue, and will help integrate localization functionalities inside the app. Even though we are using Vue I18n for Vue localization in this guide, you can use any other package or to implement your own localization solution.

To begin, let’s initialize our Vue.js project.

npm init vue@latest

Prompts for a number of optional features will appear and you can fill them in like we did or for the purpose of this tutorial:

✔ Project name: … translized-with-vue
✔ Add TypeScript? … No
✔ Add JSX Support? … Yes
✔ Add Vue Router for Single Page Application development? … No
✔ Add Pinia for state management? … No
✔ Add Vitest for Unit Testing? … No
✔ Add Cypress for both Unit and End-to-End testing? … No
✔ Add ESLint for code quality? … Yes
✔ Add Prettier for code formatting? … Yes

Once done, you can install all dependencies with:

npm install

Now we just need one more and that is Vue I18n:

npm install vue-i18n@9

And that’s it. You are ready to start your project:

npm run dev

On port 3000 your should now see the following:


Cool! We now have our project ready, and we can start its integration with a localization platform, in our case, Translized.

Initialize Project on Translized

If you still don’t have account on Translized, you can go to app and Sign up in just couple of seconds.

Once you’re inside Translized, start by creating a project.

Create Project

On the app dashboard, we have the “Add new project” card.


Name your project and set the primary language.

💡 Primary language is the primary language within the application. It’s a language most of your team members or translators who are working on your content are familiar with.

Add terms

Once you’ve added the project, it’s time to add project terms.

💡 Term will hold reference to respective translations on different languages.

There are two ways to add terms within Translized.

  1. Manually (one by one)

  2. Importing a file (in 12+ file formats supported by Translized)

In this tutorial, we’ll add just two terms to keep it simple, but feel free to add more terms if needed, or to import a bigger file with your translations.

To add term manually, navigate to:

Project > Terms > Add term

The first term we will add is:

  • Term key (Term key is term “name”, reference to that term):


  • Term context (Term context is an optional description you can add about a specific term. For example, where it will be used inside your projects, how it should be translated and more):

    • Home page main heading.

The second term will be:

  • Term key:


  • Term context:

    • Home page description about our application.

Add languages

Our next step is to translate the two terms we’ve just created so we can make our app multilingual.

Let’s add two new languages beside our primary one, Spanish and German (feel free to add different languages if you are more familiar with them).

To add new languages, navigate to:

Project > Languages > Add language

Select the language you want and click “add”.


Now that we have our new languages, let’s start translating.

Translate terms

Last but not least, let’s translate our terms. Inside the languages page, click on each language and add a proper language translation for each term.

💡 Or you can utilize the “quick translate” option available on the Project > Terms page and translate each term from there.


Our translations look like this:



    • Welcome to Translized


    • Grasp automation and deliver faster with simple, easy to use and developer friendly localization platform.



    • Bienvenido a Translized


    • Aproveche la automatización y entregue más rápido con una plataforma de localización simple, fácil de usar y amigable para el desarrollador.



    • Willkommen bei Translized


    • Erfassen Sie die Automatisierung und liefern Sie schneller mit einer einfachen, benutzerfreundlichen und entwicklerfreundlichen Lokalisierungsplattform.

That’s it. We now have our content on Translized and it’s fully ready to be shipped for English, Spanish and German audiences.

Connect Translized with Vue

We can now connect Vue.js localization with Translized. All we need is a few commands to integrate with Translized’s CLI.

💡 For more complex use cases, you can use our REST API.

If you don’t have our CLI installed yet, please refer to our CLI documentation page where you can see our step-by-step installation instructions.

Once it’s installed, go inside your terminal, in your project directory and run:

translized init

You will need to add your:

  • API key (you can find it inside the API Access page from user menu)

  • Project ID (you can find it inside your project settings page)

  • File format. Format you are using inside your code for translation files (we are using JSON)

  • Download file path. Relative path where you are keeping your localization files

  • Upload file path. Path to a single file which you, as a developer are using while developing stuff (usually it is your default language)

  • Language code of upload file.

💡 Paths should be relative, that means that you are starting from root of your project. Let’s say you want to add your localization files inside src > locale folder. Your download path should be like:



If you take a look at your files now, you’ll see that .translized.yml file has been created.

And the final step:

translized download

Awesome, our language files are inside the project with all of their respective translations!

Localize Vue.js application

Now that we have Translized connected and our localization files in place, let’s add that multilingual content to our app.

Let’s start by modifying our main.js file so it looks like this:

import { createApp } from 'vue';
import { createI18n } from 'vue-i18n';
import App from './App.vue';
// Locales
import en from './locale/en.json';
import es from './locale/es.json';
import de from './locale/de.json';
// 1. Set locale translations object
const messages = {
// 2. Create i18n instance with options
const i18n = createI18n({
locale: 'en', // set locale
fallbackLocale: 'en', // set fallback locale
messages, // our translations
// 3. Create a vue root instance
const app = createApp(App);
// 4. Install i18n instance to make the whole app i18n-aware
// 5. Mount

We’ve now added the VueI18n package to our Vue app with translation files - downloaded from Translized.

Now, it’s time to change App.vue

<script setup>
import LanguageSelect from './components/LanguageSelect.vue';
import Heading from './components/Heading.vue';
import Description from './components/Description.vue';
<LanguageSelect />
<Heading />
<Description />
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;

You will probably get errors that we don’t have our components yet, so let’s create them now.

First letls create the LanguageSelect.vue component which will be responsible for changing our locale.

<select v-model="$i18n.locale">
v-for="locale in $i18n.availableLocales"
{{ locale }}
export default {
name: 'LanguageSelect',
<style scoped></style>

In this component we have a simple select input field where options are the messages we defined inside the main.js file for Vue I18n.

Add simple components Heading.vue and Description.vue so we can see our localization in action.

Starting with Heading.vue:

<h1>{{ $t('HOME_PAGE.HEADING') }}</h1>
export default {
name: 'Heading',
<style scoped></style>

Here, we just want to make reference to our heading key, HOME_PAGE.HEADING. We will do that with Vue I18n API and $t method which is now available to us inside our components.

💡 With VueI18n, you can also add dynamic values inside your terms with special syntax.

Let’s do the same thing for Description.vue

<p>{{ $t('HOME_PAGE.DESCRIPTION') }}</p>
export default {
name: 'Description',
<style scoped></style>

When that is done and everything saved, we are ready to run our dev server again

npm run dev

You can now switch between other locales and see how translations are changing.

It’s just that simple!

Full code for this tutorial is available on codesandbox

Final words

Software localization may seem complicated at first, but with proper setup and the right tools, it doesn’t have to be. With Vue I18n and software localization platforms, such as Translized, our code can be better organized and a lot more maintainable. The best thing about this is, that as developers, we don’t have to focus on textual changes but rather on the features, meaning we can ship to our users faster.


Upgrade your product experience today

Our 14-day free trial includes 50 000 strings and unlimited projects.
View Pricing Plans to upgrade, or continue with our free plan - 1000 strings.

Try for free