Alguna forma de poner una tabla en español

Alguna forma de poner una tabla en español

silenssilens Posts: 101Questions: 40Answers: 0

Buenas amigos, mi duda es si hay alguna forma de poner las palabras de las tablas en español. por ejemplo search o entries.
Gracias

This question has an accepted answers - jump to answer

Answers

  • rf1234rf1234 Posts: 2,808Questions: 85Answers: 406
    edited August 2017

  • rf1234rf1234 Posts: 2,808Questions: 85Answers: 406
    edited August 2017

    This is the Spanish language plugin: https://datatables.net/plug-ins/i18n/Spanish

    I don't use the plugins because the translations aren't complete. Many things are missing in those files. Just check it out for yourself!

    For your reference this is how I do it. Depending on the language I change the defaults. That way I don't have to do this for the individual tables.

    So this is what I do for Editor (not in the language file). If you want to see the English defaults for Editor search for "i18n": { in file dataTables.editor.js.

    //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."
                },
            }      
        });
    }
    

    And for data tables (also see language file):

    $.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'
                }
            }
        }            
    } );        
    
  • silenssilens Posts: 101Questions: 40Answers: 0

    Muchas gracias por la respuesta, tengo algunas dudas.

    1º Como puedo poner el plugin? ¿Solo tengo que poner el enlace https://datatables.net/plug-ins/i18n/Spanish en mi index.html?

    2º And for data tables (also see language file): Donde esta ese archivo? Yo lo puedo editar?

    Yo necesito cambiar las palabras: show,entries,Search, todo lo relacionado con la tabla.
    Muchas gracias

  • rf1234rf1234 Posts: 2,808Questions: 85Answers: 406
    edited August 2017

    1 where to put it: before the end of the body of your page, i.e. before this tag: </body>

    <script src="https://cdn.datatables.net/plug-ins/1.10.15/i18n/Spanish.json"></script>
    

    2 that IS the plug in file as you can see if you click on the link. What you see in my post is my own coding. You can copy it if you like and edit it so that you have it in Spanish. What you see in the plugin might help you get the wording right.

    I am not using the plugin files because they are not complete. So you either use the plugin file or you don't. It's up to you ... I copied the plugin file into my source code and completed it by adding the missing attributes.

    As you can see the plugin file still has those prefixes like "o" and "s". This is legacy and no longer needed. So it's got to be pretty old ...

    You can also take a look at this: https://datatables.net/reference/option/language

  • silenssilens Posts: 101Questions: 40Answers: 0

    OK, muchas gracias, el caso es que he descargado el plugin y se llama se llama Spanish.lang y no .json
    Lo he editado a mi gusto y ahora lo he subido y lo he puesto en mi web renombrado como Spanish.json.

    <script src="plg/Spanish.json"></script>
    

    He realizado algún cambio pero no lo veo en la tabla, la tabla sigue mostrando show y no enseñar como yo he puesto. Q hago mal?

  • rf1234rf1234 Posts: 2,808Questions: 85Answers: 406
    edited August 2017

    Without your code I can't tell you. You should be aware that just embedding the language file doesn't do the job. You need to pass it into your data table as the language object or use it to edit the defaults as per my example above.

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

    ok, I am making an exception to get you started with this. Normally I don't write other people's code ... Please just copy this ON TOP of all of your data tables and everything should work WITHOUT any modification of your tables.

    Esto es lo que usted necesita poner en su código ANTES de sus data tablas. Y, por favor, elimine el fichero language. Usted no necesita hacer ningún cambio de sus tablas si copia esto.

    $.extend( true, $.fn.dataTable.defaults, {
        "language": {
            "decimal": ",",
            "thousands": ".",
            "info": "Mostrando registros del _START_ al _END_ de un total de _TOTAL_ registros",
            "infoEmpty": "Mostrando registros del 0 al 0 de un total de 0 registros",
            "infoPostFix": "",
            "infoFiltered": "(filtrado de un total de _MAX_ registros)",
            "loadingRecords": "Cargando...",
            "lengthMenu": "Mostrar _MENU_ registros",
            "paginate": {
                "first": "Primero",
                "last": "Último",
                "next": "Siguiente",
                "previous": "Anterior"
            },
            "processing": "Procesando...",
            "search": "Buscar:",
            "searchPlaceholder": "Término de búsqueda",
            "zeroRecords": "No se encontraron resultados",
            "emptyTable": "Ningún dato disponible en esta tabla",
            "aria": {
                "sortAscending":  ": Activar para ordenar la columna de manera ascendente",
                "sortDescending": ": Activar para ordenar la columna de manera descendente"
            },
            //only works for built-in buttons, not for custom buttons
            "buttons": {
                "create": "Nuevo",
                "edit": "Cambiar",
                "remove": "Borrar",
                "copy": "Copiar",
                "csv": "fichero CSV",
                "excel": "tabla Excel",
                "pdf": "documento PDF",
                "print": "Imprimir",
                "colvis": "Visibilidad columnas",
                "collection": "Colección",
                "upload": "Seleccione fichero...."
            },
            "select": {
                "rows": {
                    _: '%d filas seleccionadas',
                    0: 'clic fila para seleccionar',
                    1: 'una fila seleccionada'
                }
            }
        }            
    } );        
    
  • silenssilens Posts: 101Questions: 40Answers: 0

    Muchas Gracias, funciona perfectamente, ha vuelto a ayudarme. Pronto podre ayudar yo a otros.

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

    Good to know this worked for you! So now you already have three languages: Spanish, German (see the version of $.fn.dataTable.defaults that I posted initially) and of course English. In case you should use Editor you have the German version already ($.fn.dataTable.Editor.defaults above). All you would need to do is create a Spanish version from this.

    Es bueno saber que esto funcionó para usted! Así que ahora ya tiene tres idiomas: español, alemán (ver la versión de $ .fn.dataTable.defaults que posteé inicialmente) y por supuesto inglés. En caso de que utilice Editor, ya tiene la versión alemana ($ .fn.dataTable.Editor.defaults por encima ). Todo lo que necesita hacer es crear una versión en español de esto.

This discussion has been closed.