This library is a simple wrapper for i18next, simplifying its use in Vue 2.
There is also a Vue 3 version of this package.
npm install i18next-vue@vue-2import 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({ ... });Use the $t function, which works analogously to the t function found in i18next.
To learn about more options, check out the full documentation.
<i18n>
{
"en": {
"insurance": "Insurance"
},
"de": {
"insurance": "Versicherung"
}
}
</i18n>
<template>
<h1>A test in {{ $i18next.language }}</h1>
<p>{{ $t('insurance') }}</p>
</template>- node.js >= v15