浏览代码

Add i18n enhance extension.

jewway 9 年之前
父节点
当前提交
7ac7d2f248
共有 1 个文件被更改,包括 34 次插入0 次删除
  1. 34 0
      src/extensions/i18n-enhance/i18n-enhance.js

+ 34 - 0
src/extensions/i18n-enhance/i18n-enhance.js

@@ -0,0 +1,34 @@
+/**
+ * @author: Jewway
+ * @version: v1.0.0
+ */
+
+!function ($) {
+  'use strict';
+
+  var BootstrapTable = $.fn.bootstrapTable.Constructor;
+
+  BootstrapTable.prototype.changeTitle = function (locale) {
+    $.each(this.options.columns, function (idx, columnList) {
+      $.each(columnList, function (idx, column) {
+        if (column.field) {
+          column.title = locale[column.field];
+        }
+      });
+    });
+
+    this.initHeader();
+    this.initBody();
+    this.initToolbar();
+  };
+
+  BootstrapTable.prototype.changeLocale = function (localeId) {
+    this.options.locale = localeId;
+    this.initLocale();
+    this.initPagination();
+  };
+
+  $.fn.bootstrapTable.methods.push('changeTitle');
+  $.fn.bootstrapTable.methods.push('changeLocale');
+
+}(jQuery);