vuejs-lang

1.0.0 • Public • Published

vuejs-localization

Installation

$ npm install vuejs-localization --save

Setup

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 Folder

└── lang
    ├── en
    |  └──messages.js
    └── da
       └──messages.js

Lang file

//messages.js
module.exports = {
  hello_world : 'Hello World!'
}

Usage

$lang.{file}.{key}
<h1>{{$lang.messages.hello_world}}</h1>

Results in:

<h1>Hello World</h1>

Change localization (reactive)

//inside vue instance
this.$lang.setLang('pt')

Package Sidebar

Install

npm i vuejs-lang

Weekly Downloads

10

Version

1.0.0

License

ISC

Last publish

Collaborators

  • kandries