Requested unknown parameter when using `language.url`

Requested unknown parameter when using `language.url`

gian1200gian1200 Posts: 6Questions: 2Answers: 1
edited March 14 in Free community support

Link to test case:

https://live.datatables.net/vagohuwi/1/edit

Debugger code (debug.datatables.net):

Your debug code is: adudoh (tested inside the live demo)

Error messages shown:

DataTables warning: table id=tabla-resultados - Requested unknown parameter '1' for row 0, column 1. For more information about this error, please see https://datatables.net/tn/4

Description of problem:

I'm testing/playing with the internationalization feature. I even created a custom JSON to reuse its values among many tables (instead of editing them manually on each page).

However, when testing the JSON, with the language.url property, it fails.
In the Live Code you can uncomment language.url to see the error (no alert, but the table doesn't load properly.

Given that only labels are being changed, I find it weird that it fails

PS: is _ENTRIES_ not expected to work on "emptyTable"?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 22,417Questions: 26Answers: 5,154
    edited March 14 Answer ✓

    Thanks for the test case!

    This is in the language.url docs:

    Note that when this parameter is set, DataTables' initialisation will be asynchronous due to the Ajax data load. That is to say that the table will not be drawn until the Ajax request has completed. As such, any actions that require the table to have completed its initialisation should be placed into the initComplete callback.

    Basically your test case is calling table.draw() before initialization is complete causing the error. Move it into initComplete or ready() to execute after Datatables has fully initialized. Updated test case:
    https://live.datatables.net/vagohuwi/2/edit

    PS: is ENTRIES not expected to work on "emptyTable"?

    The language.emptyTable docs don't state that string substitution is available. However language.infoEmpty does have this:

    Please note that the same string substitutions available in language.info are also available in this property.

    I would say this is expected behavior since string substitution not documented to be supported. Also language.emptyTable is displayed when there are no records so the substitution values would all be zero. Do you have a use for needing to use string substitution with language.emptyTable?

    Kevin

  • gian1200gian1200 Posts: 6Questions: 2Answers: 1
    1. Awesome, thanks! I'm actually going to need both initComplete and ready(). I think I missed that section of the docs because I started reading from https://datatables.net/manual/i18n#Ajax-loading-a-translation, and stopped there.

    2. I was trying to improve the message from "No data available in table" to "No entries available in table", but in spanish (where "entries" is defined at language.entries["_"]).
      Basically, to make it work like my infoEmpty example: Switching from "Showing 0 to 0 of 0" (which doesn't really make sense) to "There are no entries to display". That way the message feels more "natural".

  • kthorngrenkthorngren Posts: 22,417Questions: 26Answers: 5,154

    was trying to improve the message from "No data available in table" to "No entries available in table", but in spanish (where "entries" is defined at language.entries["_"]).

    You will need to set the language.emptyTable string like this:

    "emptyTable": "No hay solicitudes disponibles en la tabla",

    Updated test case:
    https://live.datatables.net/vagohuwi/4/edit

    @allan will need to comment on adding the ability to use the setting from language.entries["_"].

    Kevin

  • gian1200gian1200 Posts: 6Questions: 2Answers: 1
    edited March 15

    You will need to set the language.emptyTable string like this:

    "emptyTable": "No hay solicitudes disponibles en la tabla"

    Yes, I'm currently doing that as a workaround, changing "solicitudes" accordingly for each table I have. Thanks for the suggestion!.

    Regarding the 2nd part, if it's decided to enhance the emptyTable message, could I kindly ask if zeroRecords might also be included?"

    Giancarlo

  • allanallan Posts: 65,623Questions: 1Answers: 10,910 Site admin

    Hi,

    Many thanks for this discussion. Having emptyTable and zeroRecords change based on entries certainly would make sense. I'm not sure how easy that is going to be though, as I'm concerned it wouldn't make sense in all languages - or there might be nuances that are missed.

    For example, the default for emptyTable is:

    No data available in table

    If entries is people, it wouldn't really be right to say "No people available in table". The zeroRecords flows better, but I don't know enough about other languages to be able to say how well that would work.

    What we really need is an expert in internationalisation to be able to tell us if this is viable. In the short term, I'd suggest setting emptyTable and zeroRecords as you currently need to, but it is something I will look out for as it could help improve things for both the develper and client.

    Allan

  • gian1200gian1200 Posts: 6Questions: 2Answers: 1

    Hello, Allan

    Thanks for your answer.

    I'm not talking about changing the default message in any language. For a general purpose the current message is fine.

    In Spanish, Italian, Portuguese and French your "people" example has the same issue. It might work with some tweaking, but I see your point.

    However adding the ability to use placeholders (is that the right name?) in emptyTable and zeroRecords would be a nice addition (entries, entry, etc.) and it shouldn't break anything. That way any customization of both properties could reused the correct word that is already defined.

Sign In or Register to comment.