Translation of popoverTitle for colvis?

Translation of popoverTitle for colvis?

thosefactsthosefacts Posts: 9Questions: 2Answers: 0

Hello. Is it possible to translate the popoverTitle for colvis? I have tried using

popoverTitle: function(dt) { dt.i18n('buttons.colvis.popoverTitle', '') };  

instead of a string, but this just outputs the function declaration as a text.

layout: {
            topStart: {
                buttons: [
                    {
                        extend: 'colvis',
                        columns: ':not(:first-child)',
                        popoverTitle: 'Missing translation options?',
                        postfixButtons: ['colvisRestore']
                    },
                ]
            },

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    Answer ✓

    The popoverTitle option of collection only allows a string at the moment, so you'd need to to the translation up front. There isn't currently an option to have it has a function, but I think that is a good idea and I've logged that to make the change.

    Allan

  • thosefactsthosefacts Posts: 9Questions: 2Answers: 0
    edited June 13

    Thank you for the answer, Allan. Yes it would be nice to have that as an option. I figured out that I can call the appropriate path for the translation. Short example on how it can be done:

    JSON:

    {
        "buttons": {
            "colvis": {
                "_": "Button title",
                "popoverTitle": "Popover title"
            },
        }
    }
    

    JS:

    const translations = (path to json);
    
    buttons: [
        {
            extend: 'colvis',
            columns: ':not(:first-child)',
            popoverTitle: translations.buttons.colvis.popoverTitle,
            postfixButtons: ['colvisRestore']
        }
    ],
    
Sign In or Register to comment.