patrickkunka / mixitup

A high-performance, dependency-free library for animated filtering, sorting, insertion, removal and more
https://www.kunkalabs.com/mixitup/
4.52k stars 735 forks source link

[MixitUp Pagination] Language Localised UI for Page Stats #483

Closed Scopestyle closed 5 years ago

Scopestyle commented 5 years ago

Hi Patrick,

I'm running in the situation where we want to use pagination module on a multilanguage project, and was surprised to see the little "to" and "of" are hardcoded in the JS. Perhaps it would be a good addition to be able to overwrite these without having to edit the main javascript file.

Kind regards,

Erik

patrickkunka commented 5 years ago

Hi there,

English is the default value, but can easily be overridden via the templates.pageStats, templates.pageStatsSingle and templates.pageStatsFail configuration options:

https://www.kunkalabs.com/mixitup-pagination/docs/configuration-object/

Here's an example in French for you:

const mixer = mixitup(container, {
    pagination: {
        limit: 8
    },
    templates: {
        pageStats: '${startPageAt} à ${endPageAt} sur ${totalTargets}',
        pageStatsSingle: '${startPageAt} à ${endPageAt}',
        pageStatsFail: 'Nuls rèsultats'
   }
}

Obviously these are hardcoded into the config in the example, but in a real application you would create a set of all your templates for each language, and then inject the appropriate set into the config at runtime.