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
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • 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
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(