Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Django localisation with Flatpickr

Hi,

I 'd like use Flatpickr ( for example) in French. But i don't understand how with django view and Js. Thanks for your help

My wiew

class PublicationsAddView(LoginRequiredMixin, TemplateView):

    template_name = 'pages/publications/add.html'
    form = forms.PublicationForm()

    def get_context_data(self, **kwargs):

        context = super().get_context_data(**kwargs)

        context.update({'form': self.form})

        context = KTLayout.init(context)

       # Js intégration for flatpickr
        KTTheme.addJavascriptFile("js/publications/add.js")
       # French traduction
        KTTheme.addJavascriptFile("js/publications/flatpickr_fr.js")
        
        return context

My JS file

$("#kt_datepicker_2").flatpickr({
    locale: "fr",
    dateFormat: "d-m-Y",
});
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (1)


Hi RT,

Sorry for the delay. In the build tool config file starterkit/_keenthemes/tools/gulp.config.js

Could you please try to include flatpickr localization file?


flatpickr: {
styles: [
"{$config.path.node_modules}/flatpickr/dist/flatpickr.css",
],
scripts: [
"{$config.path.node_modules}/flatpickr/dist/flatpickr.js",
"{$config.path.node_modules}/flatpickr/dist/l10n/fr.js"
],
},


Then build the assets using gulp.



$("#kt_datepicker_2").flatpickr({
locale: "fr",
dateFormat: "d-m-Y",
});


Thanks


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(