1 | import { warn } from './util'
|
2 | import extend from './extend'
|
3 | import mixin from './mixin'
|
4 | import component from './component'
|
5 | import { bind, update, unbind } from './directive'
|
6 |
|
7 | export let Vue
|
8 |
|
9 | export function install (_Vue) {
|
10 |
|
11 | if (process.env.NODE_ENV !== 'production' && install.installed && _Vue === Vue) {
|
12 | warn('already installed.')
|
13 | return
|
14 | }
|
15 | install.installed = true
|
16 |
|
17 | Vue = _Vue
|
18 |
|
19 | const version = (Vue.version && Number(Vue.version.split('.')[0])) || -1
|
20 |
|
21 | if (process.env.NODE_ENV !== 'production' && version < 2) {
|
22 | warn(`vue-i18n (${install.version}) need to use Vue 2.0 or later (Vue: ${Vue.version}).`)
|
23 | return
|
24 | }
|
25 |
|
26 | extend(Vue)
|
27 | Vue.mixin(mixin)
|
28 | Vue.directive('t', { bind, update, unbind })
|
29 | Vue.component(component.name, component)
|
30 |
|
31 |
|
32 | const strats = Vue.config.optionMergeStrategies
|
33 | strats.i18n = function (parentVal, childVal) {
|
34 | return childVal === undefined
|
35 | ? parentVal
|
36 | : childVal
|
37 | }
|
38 | }
|