Localisation of date picker

Localisation of date picker

fabioberettafabioberetta Posts: 74Questions: 23Answers: 4
edited January 2021 in Editor

Good afternoon,

I am adding language option to a page and need to have the datepicker localised.

I have found this: https://editor.datatables.net/examples/dates/i18n.html

Adding i18n data to each table is a bit annoying and I would like to have something I can configure at least per page.

I have tryied to configure each field like this:

{
                    label: "Date de naiss.",
                        name: "child.birth_date",
                        type:   'datetime',
                        format: 'YYYY-MM-DD',
                        opts: {
                            momentLocale: 'fr'
                        }

                }

But I did not mange to make it work. How could I do it?

Thanks,
Fabio

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 61,773Questions: 1Answers: 10,112 Site admin
    Answer ✓

    Hi Fabio,

    You can set the defaults for the date time picker's language strings using the object:

    $.fn.dataTable.Editor.DateTime.defaults.i18n
    

    e.g. you could do:

    $.extend( $.fn.dataTable.Editor.DateTime.defaults.i18n, {
      previous: 'Prev',
      ...
    } );
    

    Allan

  • fabioberettafabioberetta Posts: 74Questions: 23Answers: 4

    Hi Allan,

    thanks for the tip.

    I used this solution. I have added a javascript array with all i18n strings and assigned as default at the beginning of each page.

    On the other hand I did not find any i18n data for the upload field (to convert buttons, drop area text...). I had to assign them in each individual editor. Any better solution?

    Thanks,
    Fabio

  • allanallan Posts: 61,773Questions: 1Answers: 10,112 Site admin
    Answer ✓

    Hi Fabio,

    At the moment, no - the upload strings are assigned on a per instance basis and do not have a way to be assigned defaults. I need to look at adding that.

    Regards,
    Allan

This discussion has been closed.