0

Hi i followed the datepicker process in order to change the language via the sample: https://jqueryui.com/datepicker/#localization

The problem is that the event is not working, the files are loaded. and it chnages the format, but only for the last imported datepicker: example:

  1. i18n/datepicker-en.js
  2. i18n/datepicker-fr.js
  3. i18n/datepicker-zh.js <- Thuis gets loaded.

i tried binding an event to a button:

`

var changeLang = function() {
    var language = $.cookie('date_format')
    language ='fr'
    var picker1= $('#dateStart').datepicker
    $('#dateStart').datepicker( $.datepicker.regional[ language ] );
    var picker2= $('#dateStart').datepicker
    $('#dateEnd').datepicker( $.datepicker.regional[ language ] );
    $('#dateShift').datepicker( $.datepicker.regional[ language ] ); 
}


<button onclick="changeLang()">Test</button> 

`

I tried binding on load, document.ready nothing works. Any tips?

Thank you

1 Answers1

0

Well, i didnt find a solution for that problem but made a work around.

By dynamically loading the correct script:

var language = 'fr'
var head = $('head');
var scripts = document.head.getElementsByTagName('script');
$('#src_date_format').remove();
var script = document.createElement('script');
script.id = 'src_date_format';
script.src = '/portal/static/js/i18n/ui.datepicker-'+language+'.js'
head[0].append(script);