Fork me on GitHub

Changing the language for Bootstrap Date Paginator


This is a standard initialization of the Bootstrap Date Paginator plugin


Code

This is where the magic happens (inside the _buildData method's loop). The plugin uses version 2.4.0 of the MomentJS library, where the language changing method was lang. Howevere, newer versions of MomentJS use locale. The change supports both

For more info, read my blog post: changing the language for the Bootstrap Date Paginator plugin

            
                for (var m = start; m.isBefore(end); m.add('days', 1)) {

                    if (this.options.language) {
                        if (typeof m.lang === 'function') {
                            m.lang(this.options.language);
                        } else if (typeof m.locale === 'function') {
                            m.locale(this.options.language);
                        }
                    }