Why did my Datatable didn't change the language?

Why did my Datatable didn't change the language?

daschebergdascheberg Posts: 3Questions: 1Answers: 0

I'm a newbie of using Datatables and have some problems. The string parts of the table, like "showing n to nn of nn entries" will not be shown in german. Also I can't select some row. I don't know why. Here the first lines of my php-file:

'''<!DOCTYPE html>

<html>

<header align="center">
<title>Die Weg-sind-sie Website</title>

<link rel = stylesheet href = "./scr/CSS/wss.css"/>
                                                     -
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/jq-3.3.1/jszip-2.5.0/dt-1.10.23/af-2.3.5/b-1.6.5/b-colvis-1.6.5/b-flash-1.6.5/b-html5-1.6.5/b-print-1.6.5/fc-3.3.2/fh-3.1.8/r-2.2.7/sc-2.0.3/sb-1.0.1/sp-1.2.2/sl-1.3.1/datatables.min.css"/>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/jq-3.3.1/jszip-2.5.0/dt-1.10.23/af-2.3.5/b-1.6.5/b-colvis-1.6.5/b-flash-1.6.5/b-html5-1.6.5/b-print-1.6.5/fc-3.3.2/fh-3.1.8/r-2.2.7/sc-2.0.3/sb-1.0.1/sp-1.2.2/sl-1.3.1/datatables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.22/i18n/German.json"></script>

    <script>
        $(document).ready( function () {
            $('#table-id-1').DataTable({
                paging: true,
                ordering: true,
                info: true,
                search: true,
                autoWidth: false,
            });
        } );
    </script>

    <script>
        $('#table-id-1').DataTable({
        language: {
            select: {
                rows: {
                    _: "ausgew&aumlhlt: %d Zeilen",
                    0: "Click eine Zeile zum ausw&aumlhlen",
                    1: "ausgew&aumlhlt:  1 Zeile"
                }
            }
        },
        select: true
        } );
    </script>



    <h2><i>N&aumlhrwerttabelle</i></h2>
    (Werte pro 100 Gramm)

</header>

<body>

<?php '''

The webpage: wss.dascheberg.de

It would be great if somebody can help me.

Dieter Ascheberg

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,770
    Answer ✓

    You need to combine all the initialization options into one Datatables initialization call. Like this example:
    http://live.datatables.net/fokezufi/1/edit

    Kevin

  • colincolin Posts: 15,144Questions: 1Answers: 2,586
    Answer ✓

    The easiest way is to use the pre-supplied language file, as shown in this example. Though you should be able to specify individual strings like you're trying to do.

    Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.

    Cheers,

    Colin

  • daschebergdascheberg Posts: 3Questions: 1Answers: 0

    Thanls for help, now i change the js script as follows and it works:

    "

    $(document).ready( function () { $('#table-id-1').DataTable({ language: { url: "https://cdn.datatables.net/plug-ins/1.10.22/i18n/German.json", select: { rows: { _: "
    ausgewälhlt: %d Zeilen", 0: "
    Click eine Zeile zum auswählen", 1: "
    ausgewählt: 1 Zeile" } } }, search: "Suchbegriff", select: true, paging: true, ordering: true, info: true, search: true, autoWidth: false }); } );

    "

    Now I have what I want and understand the syntax a little bit more. Thank you for the assistance. (you can see it on wss.dascheberg.de).
    Dieter

  • daschebergdascheberg Posts: 3Questions: 1Answers: 0

    Thanks, now it works. Thanks a lot.

This discussion has been closed.