Skip to content
This repository has been archived by the owner on Apr 30, 2020. It is now read-only.

hpi-schul-cloud/vuejs-localization

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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
    └── pt
       └──messages.js

Lang file

//messages.js
export default {
  hello_world : 'Hellow 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')

About

This Project was forked because it wasn't working with vue-cli 3 by default

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%