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
<pre> 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 </pre>My JS file
<pre> $("#kt_datepicker_2").flatpickr({ locale: "fr", dateFormat: "d-m-Y", }); </pre>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