Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angularjs change language ui-grid options

I'm using angular ui-grid not ng-grid. how can I to change the language english to spanish of the grid options.

like image 962
cristianqr Avatar asked Dec 24 '22 15:12

cristianqr


1 Answers

The solution I found is to change the default language of the service i18nService on the controller or in a configuration file. as following:

Set default language on the controller

var app = angular.module('moduleName');
app.controller('testController', ['i18nService', function(i18nService){
    //es is the language prefix you want
    i18nService.setCurrentLang('es');
}]);

Set default language in a configuration file

var app = angular.module('moduleName');
app.config(function($provide){
    $provide.decorator('GridOptions',['$delegate', 'i18nService', function($delegate, i18nService){
        var gridOptions;
        gridOptions = angular.copy($delegate);
        gridOptions.initialize = function(options) {
            var initOptions;
            initOptions = $delegate.initialize(options);
            return initOptions;
        };
        //es is the language prefix you want
        i18nService.setCurrentLang('es');
        return gridOptions;
    }]);
});
like image 101
cristianqr Avatar answered Dec 27 '22 05:12

cristianqr