index.js 719 B

123456789101112131415161718192021222324252627
  1. import Vue from 'vue';
  2. import { deepAssign } from '../utils/deep-assign';
  3. import defaultMessages from './lang/zh-CN';
  4. var proto = Vue.prototype;
  5. var defineReactive = Vue.util.defineReactive;
  6. defineReactive(proto, '$vantLang', 'zh-CN');
  7. defineReactive(proto, '$vantMessages', {
  8. 'zh-CN': defaultMessages
  9. });
  10. export default {
  11. messages: function messages() {
  12. return proto.$vantMessages[proto.$vantLang];
  13. },
  14. use: function use(lang, messages) {
  15. var _this$add;
  16. proto.$vantLang = lang;
  17. this.add((_this$add = {}, _this$add[lang] = messages, _this$add));
  18. },
  19. add: function add(messages) {
  20. if (messages === void 0) {
  21. messages = {};
  22. }
  23. deepAssign(proto.$vantMessages, messages);
  24. }
  25. };