$ npm install vuejs-localization --save
var Vue = require('vue');
var Lang = require('vuejs-localization');
//Notice that you need to specify the lang folder, in this case './lang'
Lang.requireAll(require.context('./lang', true, /\.js$/));
Vue.use(Lang);
└── lang
├── en
| └──messages.js
└── pt
└──messages.js
//messages.js
module.exports = {
hello_world : 'Hello World!'
}
$lang.{file}.{key}
<h1>{{$lang.messages.hello_world}}</h1>
Results in:
<h1>Hello World</h1>
//inside vue instance
this.$lang.setLang('pt')