Browse Source

Don't overwrite custom locale functions

Dustin Utecht 4 years ago
parent
commit
f34a06e992
1 changed files with 13 additions and 3 deletions
  1. 13 3
      src/bootstrap-table.js

+ 13 - 3
src/bootstrap-table.js

@@ -67,12 +67,22 @@ class BootstrapTable {
         parts[1] = parts[1].toUpperCase()
       }
 
+      let localesToExtend = {}
+
       if (locales[this.options.locale]) {
-        $.extend(this.options, locales[this.options.locale])
+        localesToExtend = locales[this.options.locale]
       } else if (locales[parts.join('-')]) {
-        $.extend(this.options, locales[parts.join('-')])
+        localesToExtend = locales[parts.join('-')]
       } else if (locales[parts[0]]) {
-        $.extend(this.options, locales[parts[0]])
+        localesToExtend = locales[parts[0]]
+      }
+
+      for (const [formatName, func] of Object.entries(localesToExtend)) {
+        if (this.options[formatName] !== BootstrapTable.DEFAULTS[formatName]) {
+          continue
+        }
+
+        this.options[formatName] = func
       }
     }
   }