p:datatable sort language with responsive reflow = “true”

前端 未结 2 1262
忘掉有多难
忘掉有多难 2021-01-24 09:46

How can I change the language for Sorting on PF DataTable component with reflow = \"true\" (so responsive Datatable)?

The problem is that on mobile screen, we can sort d

相关标签:
2条回答
  • 2021-01-24 10:04

    I never ran into this or used it, but I know the source is open. So I went to the javascript file for the datatable. There I searched for 'Ascending' and via this.ascMessage, I ended up on line 170 where 'datatable.sort.ASC' is used as a key.

    This in turn points to line 619 in core.js

    getAriaLabel: function(key) {
            var ariaLocaleSettings = this.getLocaleSettings()['aria'];
            return (ariaLocaleSettings&&ariaLocaleSettings[key]) ? ariaLocaleSettings[key] : PrimeFaces.locales['en_US']['aria'][key];
    },
    

    Where you can see the normal PrimeFaces locale functionality is used.

    So using your own locale and overriding this part in it, like in the default locale

    aria: {
        'paginator.PAGE': 'Page {0}',
        'calendar.BUTTON': 'Show Calendar',
        'datatable.sort.ASC': 'activate to sort column ascending',
        'datatable.sort.DESC': 'activate to sort column descending',
        'columntoggler.CLOSE': 'Close'
    }
    

    Will solve your issue I would expect

    0 讨论(0)
  • 2021-01-24 10:19

    The intended way to do this is to define the following properties in your resource files (see Messages.properties)

    primefaces.datatable.SORT_LABEL = Sort
    primefaces.datatable.SORT_ASC = Ascending
    primefaces.datatable.SORT_DESC = Descending
    

    You can see this when you look at the DatatableRender of primefaces.

    Notice i18n is done in different ways in primefaces. Some components like calendar or schedule must be translated via javascript. See here

    0 讨论(0)
提交回复
热议问题