Skip to content

i18next/i18next-vue

 
 

Repository files navigation

i18next-vue

Introduction

This library is a simple wrapper for i18next, simplifying its use in Vue 2.

There is also a Vue 3 version of this package.

Installation

npm install i18next-vue@vue-2

Initialisation

import Vue from "vue";
import i18next from "i18next";
import I18NextVue from "i18next-vue";
import App from "./App.vue";

Vue.use(I18NextVue, { i18next });

i18next.on("initialized", () => {
    new Vue({
        render: h => h(App),
    }).$mount("#app");
});

i18next.init({ ... });

Usage

Use the $t function, which works analogously to the t function found in i18next.

To learn about more options, check out the full documentation.

Simple example

<i18n>
{
    "en": {
        "insurance": "Insurance"
    },
    "de": {
        "insurance": "Versicherung"
    }
}
</i18n>

<template>
    <h1>A test in {{ $i18next.language }}</h1>
    <p>{{ $t('insurance') }}</p>
</template>

Contributing

Requirements

  • node.js >= v15

About

Internationalization for Vue 2 & 3 using the i18next ecosystem

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 18