uxsolutions / bootstrap-datepicker

A datepicker for twitter bootstrap (@twbs)
Apache License 2.0
12.67k stars 6.06k forks source link

require js and localisation #2225

Open felek000 opened 7 years ago

felek000 commented 7 years ago

Expected behaviour

Hello I import datepicker using require js but i can't add localisation support. I search on web and i found no solution how to add language current i have is default En. When i'm import like i code bellow i get data error.

require.config({
    paths: {
        'jQuery': 'https://code.jquery.com/jquery-3.2.1.min',
        "bootstrap": "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min",
        'moment':'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment-with-locales.min',
        'lodash':'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min',
        'select2':'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.full.min',
        'datepicker':'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.0/js/bootstrap-datepicker.min',
        'datepickerLocale':'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.0/locales/bootstrap-datepicker.pl.min',
        'mCustomScrollbar':'https://cdnjs.cloudflare.com/ajax/libs/malihu-custom-scrollbar-plugin/3.1.5/jquery.mCustomScrollbar.min',

        'material':'otherLibs/material',
        'ripples':'otherLibs/ripples',
        'mainFilter':'main-filter',
        'events':'events',

    },
    shim: {
        'jQuery': {exports: '$'},
        'moment': {exports: 'moment'},
        'bootstrap' : { 'deps' :['jQuery'] },
        'select2' : { 'deps' :['jQuery'] },
        // 'app' : { 'deps' :['jQuery','helperFunctions'] },
        'events' : { 'deps' :['jQuery'] },
        'fullCalendar' : { 'deps' :['jQuery','fullCalendarLang'] },
        'mCustomScrollbar' : { 'deps' :['jQuery'] },
        'datepicker' : { 'deps' :['jQuery','moment','datepickerLocale'] },
        'ripples' : {'deps': ['jQuery','bootstrap']},
        'material' : {'deps': ['jQuery','bootstrap']},
    }
});
NielsNet commented 7 years ago

Try setting the datepicker as a dependency for the datepickerLocale. Then you can call the datepickerLocale via requireJS and it will get the datepicker befor executing anything.