Plugins i18n using external file

Plugins i18n using external file

signalsignal Posts: 3Questions: 1Answers: 0

Using file for datatable i18n is useful, but this is not possibile for plugins such as editors os select. These plugins use translate string inside the costructor and is not possibile using an external file ( there's no url object ). Is there a way to add this? Maybe using one single file for all the plugins?

Answers

  • nessinitsnessinits Posts: 86Questions: 27Answers: 0

    Do you mean plugins used by datatables itself or plugins you added?

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Hi @signal ,

    For Select and for Editor, you can use i18n() or language as in this example, likewise Editor. Those values could be stored in a file and loaded as in this example here.

    Hope that helps,

    Cheers,

    Colin

  • signalsignal Posts: 3Questions: 1Answers: 0

    @nessinits plugins used by datatables, like Editors and Select
    @colin Sure, but i don't understand how use file with plugin. If you see this example here this is json file, how can i convert this code
    select: {
    rows: {
    _: "You have selected %d rows",
    0: "Click a row to select it",
    1: "Only 1 row selected"
    }
    }

    and put in the json file?

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Hi @signal ,

    The best bet is to look at that example above - or this file: http://cdn.datatables.net/plug-ins/1.10.16/i18n/German.json . To add other language extensions, follow the same format, i.e. add this to the end of the file (within the final curly brackets) - see attached file.

      select: {
            rows: {
          _: '%d Zeilen ausgewählt',
          0: 'Zum Auswählen auf eine Zeile klicken',
          1: '1 Zeile ausgewählt'
            }
      }
    

    Cheers,

    Colin

  • signalsignal Posts: 3Questions: 1Answers: 0

    @colin, this can't be done! You can't mix json and js!

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Did you see that link I posted above showing it being done... Here it is: https://datatables.net/examples/advanced_init/language_file.html

This discussion has been closed.