translation for select - not working

translation for select - not working

protomeprotome Posts: 25Questions: 11Answers: 1
edited February 2017 in Free community support

Hello
I am having a little problem
for the language translation, in my table definition I use : "language": dtLanguage()
and then (using i18next) in my specific language file, I have all the translations. This works perfectly but for the select part.
This is what I added in my translation file - can anybody see where is the error ? the translation file does not, it serves everything else (buttons etc) correctly, but all the selects (and only them) are still in english. I am using the latest datatable. Any idea of where/what to check is very much welcome - merci

  "select": {
    "rows": {
        "_": " %d lignes sélectionnées",
        "0": "Cliquer pour sélectionner",
        "1": "1 ligne sélectionnée"
     }
  },
 "buttons":{
   "copySuccess":{
       "1":"Copier une ligne dans le presse-papier",
       "_":"copier %d lignes dans le presse-papier"
      }
   }

Answers

  • rf1234rf1234 Posts: 2,808Questions: 85Answers: 406

    Don't really see what the issue is ... maybe it helps to look at my stuff which is working (took me quite a while ...)

    $.extend( true, $.fn.dataTable.defaults, {
    "language": {
        "decimal": ",",
        "thousands": ".",
        "info": "Anzeige _START_ bis _END_ von _TOTAL_ Einträgen",
        "infoEmpty": "Keine Einträge",
        "infoPostFix": "",
        "infoFiltered": " - gefiltert aus insgesamt _MAX_ Einträgen",
        "loadingRecords": "Bitte warten Sie - Daten werden geladen ...",
        "lengthMenu": "Anzeigen von _MENU_ Einträgen",
        "paginate": {
            "first": "Erste",
            "last": "Letzte",
            "next": "Nächste",
            "previous": "Zurück"
        },
        "processing": "Verarbeitung läuft ...",
        "search": "Suche:",
        "searchPlaceholder": "Suchbegriff",
        "zeroRecords": "Keine Daten! Bitte ändern Sie Ihren Suchbegriff.",
        "emptyTable": "Keine Daten vorhanden",
        "aria": {
            "sortAscending":  ": aktivieren, um Spalte aufsteigend zu sortieren",
            "sortDescending": ": aktivieren, um Spalte absteigend zu sortieren"
        },
        //only works for built-in buttons, not for custom buttons
        "buttons": {
            "create": "Neu",
            "edit": "Ändern",
            "remove": "Löschen",
            "copy": "Kopieren",
            "csv": "CSV-Datei",
            "excel": "Excel-Tabelle",
            "pdf": "PDF-Dokument",
            "print": "Drucken",
            "colvis": "Spalten Auswahl",
            "collection": "Auswahl",
            "upload": "Datei auswählen...."
        },
        select: {
            rows: {
                _: '%d Zeilen ausgewählt',
                0: 'Zeile anklicken um auszuwählen',
                1: 'Eine Zeile ausgewählt'
            }
        }
    } 
    
  • allanallan Posts: 61,715Questions: 1Answers: 10,108 Site admin

    We'd probably need to see the page or at least the full code to understand why your code isn't working.

    Allan

  • protomeprotome Posts: 25Questions: 11Answers: 1
    edited February 2017

    @rf1234 indeed problem solved
    I added

          "language": {
              select: {
                  rows: {
                      _: i18next.t('select.rows._'),
                      0: i18next.t('select.rows.0'),
                      1: i18next.t('select.rows.1')
                  }
              }
          }
    

    the translations are thus all in the same format, read from translations.json

    I just realised that I was mistaken in the way I was doing it. This is how I did the others -
    working to much ;)

    Thanks for the help and the patience
    Pat

  • rf1234rf1234 Posts: 2,808Questions: 85Answers: 406

    You are welcome, Pat. Just in case you or someone else need this for Editor as well. I gathered this:

    //Editor default settings!
        if (lang === 'de') {
            $.extend( true, $.fn.dataTable.Editor.defaults, {            
                i18n: {
                    remove: {
                        button: "Löschen",
                        title:  "Eintrag löschen",
                        submit: "Endgültig Löschen",
                        confirm: {
                            _: 'Sind Sie sicher, dass Sie die %d ausgwählten Zeilen löschen wollen?',
                            1: 'Sind Sie sicher, dass Sie die ausgewählte Zeile löschen wollen?'
                        }
                    },
                    edit: {
                        button: "Bearbeiten",
                        title:  "Eintrag bearbeiten",
                        submit: "Änderungen speichern"
                    },
                    create: {
                        button: "Neuer Eintrag",
                        title:  "Neuen Eintrag anlegen",
                        submit: "Neuen Eintrag speichern"
                    },
                    datetime: {
                previous: 'Zurück',
                next:     'Weiter',
                months:   [ 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember' ],
                weekdays: [ 'So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa' ],
                amPm:     [ 'am', 'pm' ],
                unknown:  '-'
                    },
                    error: {            
                system: "Ein Systemfehler ist aufgetreten (<a target=\"_blank\" href=\"//datatables.net/tn/12\">Für mehr Informationen</a>)."
            },
                    multi: {
                title: "Mehrere Werte",         
                            info: "Die ausgewählten Elemente enthalten verschiedene Werte für das Feld. Um alle Elemente für diess Feld auf den gleichen Wert zu setzen, klicken Sie bitte hier. Ansonsten werden die Elemente ihren jeweiligen Wert behalten.",
                restore: "Änderungen rückgängig machen",
                noMulti: "Dieses Feld kann einzeln bearbeitet werden, aber nicht als Teil einer Gruppe."
            },
                }      
            });
        }
    
  • protomeprotome Posts: 25Questions: 11Answers: 1

    sorry, I had forgotten how I solved the problem the first time around, so here is my solution - I am using i18n for all the translations, I have users for various languages

    I created a function dtLanguage() as

      function dtLanguage() {
       var val= {
          "sEmptyTable":  i18next.t('sEmptyTable'),
       "sInfo":           i18next.t('sInfo'),
       "sInfoEmpty":      i18next.t('sInfoEmpty'),
       "sInfoFiltered":   i18next.t('sInfoFiltered'),
       "sInfoPostFix":    i18next.t('sInfoPostFix'),
       "sInfoThousands":  i18next.t('sInfoThousands'),
       "sLengthMenu":     i18next.t('sLengthMenu'),
       "sLoadingRecords": i18next.t('sLoadingRecords'),
       "sProcessing":     i18next.t('sProcessing'),
       "sSearch":         i18next.t('sSearch'),
       "sZeroRecords":    i18next.t('sZeroRecords'),
       "oPaginate": {
          "sFirst":      i18next.t('oPaginate.sFirst'),
          "sPrevious":   i18next.t('oPaginate.sPrevious'),
          "sNext":       i18next.t('oPaginate.sNext'),
          "sLast":       i18next.t('oPaginate.sLast')
       },
       "oAria": {
        "sSortAscending":  i18next.t('oAria.sSortAscending'),
        "sSortDescending": i18next.t('oAria.sSortDescending')
         },
        "select": {
           "rows": {
            "_": i18next.t('select.rows._'),
            "0": i18next.t('select.rows.0'),
            "1": i18next.t('select.rows.1')
           }
         }
        };
        return val;
        }
    

    then in the tables I have

          "language":dtLanguage()
    

    All works well when I remember what I have been doing ... but like this I can have a multilane applications, depending on the user needs.

    Hope this can help somebody.

    Pat

  • allanallan Posts: 61,715Questions: 1Answers: 10,108 Site admin

    Awesome. Thanks for sharing the knowledge everyone :smile:.

    I love this community!

    Allan

This discussion has been closed.