Editor field tags not applying i18n language

Editor field tags not applying i18n language

ASST_BrianzaASST_Brianza Posts: 2Questions: 1Answers: 0

Hello,
I'm sure I'm missing something, but I can't see what or where.

I want to apply a different language to tags field in Editor through JSON file.
I downloaded the latest JSON file for my language (italian) and I tried to add the translation in different manners, without any success.
- added as "first level" as "tags: {}"
- added as "field": { "tags": {}}"
- added under "editor" as the two previous tries.
- added also as "autocomplete" (without removing "tags")

None of the above worked. Even adding directly in-code using i18n option is not working,

It only worked by editing the javascript file directly (which is something I'd like to avoid).

DataTable and Editor are all in italian, but the tags fields, so json file is correct and loaded.

What I'm missing here?

Thank you,
Fabio

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 64,624Questions: 1Answers: 10,684 Site admin

    The tags input has three strings it can display (other than the tags themselves of course):

                tags: {
                    addButton: '+ Add',
                    noResults: 'No results found',
                    placeholder: 'Type to search'
                },
    

    Are those the strings that you are referring to? Can you show me how you are adding them to the language file?

    Allan

  • ASST_BrianzaASST_Brianza Posts: 2Questions: 1Answers: 0

    Thank you for the answer!

    Here the screens of the part of the json (download from the DT repo on github) I used.

    Attempt 1:

    Attempt 2:

    I also tried the same as above, but moved inside the "editor" key.

    All attempts have been ignored, and language remained in english.

    FYI, "autocomplete" key was my personal long-shot tentative :smile:

    Thank you again!
    Fabio

  • allanallan Posts: 64,624Questions: 1Answers: 10,684 Site admin
    Answer ✓

    Hi Fabio,

    Thanks - I do indeed see the problem. Many thanks for the extra details. At the moment the workaround would be to set the values on the Editor default object:

    $.extend(DataTable.Editor.defaults.i18n.field.tags, {
      addButton: '+ A',
      noResults: 'B',
      placeholder: 'C'
    });
    

    https://live.datatables.net/jorutoji/108/edit

    I'm going to have to have a think about how to handle this. The problem is that the field is created and the language strings parsed before the DataTable has even been created, nevermind it having sent and received a response to an Ajax request for language information.

    Possibly I'll need to update the language strings dynamically, which is more overhead than I'd wanted, but I'm not currently seeing an alternative. I'll need to mull this one over a bit!

    Allan

Sign In or Register to comment.