Why dataTable is not working correctly after I use "url":"\Scripts\Chinese.lang" for "language"

Why dataTable is not working correctly after I use "url":"\Scripts\Chinese.lang" for "language"

njuhobbynjuhobby Posts: 1Questions: 1Answers: 0

I specify the 'language' object in the dataTable definition like this to do Internationalisation:

$("#rentsTable").DataTable({
            language: {
                processing: "处理中...",
                search: "搜索 ",
                lengthMenu: "显示 _MENU_ 项结果",
                info: "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 项",
                infoEmpty: "显示第 0 至 0 项结果,共 0 项",
                infoFiltered: "(由 _MAX_ 项结果过滤)",
                infoPostFix: "",
                loadingRecords: "载入中...",
                zeroRecords: "没有匹配结果",
                emptyTable: "表中数据为空",
                paginate: {
                    first: "首页",
                    previous: "上页",
                    next: "下页",
                    last: "末页"
                },
                aria: {
                    sortAscending: ": 以升序排列此列",
                    sortDescending: ": 以降序排列此列"
                }
            },
            serverSide: true,
            autoWidth: false,
            ordering: true,
            processing: false,
            order: [[0, "asc"]],
            dom: '<"#dataTableLength"l><"#dataTableFilter"f><"#dataTable"rt><"#dataTableInfo"i><"#dataTablePaging"p>',
            columnDefs: [
                { "name": "CompanyName", "targets": 0 },
                { "name": "RentStatus", "targets": 1 },
            ],
            ajax: {
                type: "POST",
                url: "@Url.Action("GetCompanyRentStatusJson", "EstateManagement")",
                dataType: "json",
                data: function (d) {
                    return { 'data': JSON.stringify(d) };
                }
            }
        });

Everything works well. However, this is simply too many words and not professional at all. I was trying to put the language in a script and use "url":"/(Script_path)/(the_script_name)" to localize the data table. So I tried this:

 $("#rentsTable").DataTable({
            language: {
                "url":"/Scripts/Chinese.lang"
            },
            serverSide: true,
            autoWidth: false,
            ordering: true,
            processing: false,
            order: [[0, "asc"]],
            dom: '<"#dataTableLength"l><"#dataTableFilter"f><"#dataTable"rt><"#dataTableInfo"i><"#dataTablePaging"p>',
            columnDefs: [
                { "name": "CompanyName", "targets": 0 },
                { "name": "RentStatus", "targets": 1 },
            ],
            ajax: {
                type: "POST",
                url: "@Url.Action("GetCompanyRentStatusJson", "EstateManagement")",
                dataType: "json",
                data: function (d) {
                    return { 'data': JSON.stringify(d) };
                }
            }
        });

The datatable was translated into Chinese after I made the change. However, the data was not loaded. Can anyone tell me what am I doing wrong here? Thanks.

This discussion has been closed.