Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Translate Angular-UI pagination

How can I translate text in Bootstrap UI pagination directive?

I've overrided the constants like this for french translation:

angular.module('myapp', ['ui.bootstrap'])
    .constant('paginationConfig', {
        itemsPerPage: 10,
        boundaryLinks: false,
        directionLinks: true,
        firstText: 'Premier',
        previousText: 'Précédent',
        nextText: 'Suivant',
        lastText: 'Dernier',
        rotate: true
    })

But overriding constants seems to be a bad idea...

What is the correct way (if any) to do this?

like image 776
Maxence Avatar asked Oct 26 '13 16:10

Maxence


1 Answers

Rather than overiding the whole constant object you can modify properties of it within the run method

var app=angular.module('myapp', ['ui.bootstrap']);

app.run(function(paginationConfig){
   paginationConfig.firstText='MY FIRST';
   paginationConfig.previousText='YOUR TEXT';

})

DEMO

In new version of ui.bootstrap you should use

uibPaginationConfig

insted of

paginationConfig
like image 145
charlietfl Avatar answered Nov 12 '22 00:11

charlietfl