All files / src/locale index.js

66.66% Statements 6/9
0% Branches 0/1
33.33% Functions 1/3
66.66% Lines 6/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33            7x           7x 7x   7x 7x       2589x                        
import Vue from 'vue';
 
import enUS from './lang/en-US.json';
import zhCN from './lang/zh-CN.json';
import ja from './lang/ja.json';
 
const defaultMessages = {
    'zh-CN': zhCN,
    'en-US': enUS,
    ja,
};
 
const proto = Vue.prototype;
const { defineReactive } = Vue.util;
 
defineReactive(proto, '$CloudUILang', 'zh-CN');
defineReactive(proto, '$CloudUIMessages', defaultMessages);
 
export default {
    messages() {
        return proto.$CloudUIMessages[proto.$CloudUILang];
    },
 
    use(lang, messages) {
        proto.$CloudUILang = lang;
        this.add({ [lang]: messages });
    },
 
    add(messages = {}) {
        Object.assign(proto.$CloudUIMessages, messages);
    },
};