Search code examples
angularjsangular-ui-gridangular-translate

How to add custom translation to ui-grid?


Official docs only showcase picking from existing translations. I tried to use code used by ui-grid itself, but it wont work for me for whatever reason:

(function () {
angular.module('ui.grid').config(['$provide', function($provide) {
  $provide.decorator('i18nService', ['$delegate', function($delegate) {
    $delegate.add('pl', {
          groupPanel: {
            description: 'Przeciągnij nagłówek kolumny tutaj, aby pogrupować według niej.'
          },
          sort: {
            ascending: 'Sortuj rosnąco',
            descending: 'Sortuj malejąco',
            remove: 'Wyłącz sortowanie'
          },
        }
      });
      return $delegate;
    }]);
  }]);
})();

What is proper way to achieve above goal?


Solution

  • Being ui-grid an open source project, the proper way to add a non existing language would be to add it to the source and ask the team to accept your edits.

    If you're not accustomed to the way the project works you can take a look at these docs:

    As to why your code is not working, I don't know :D because it's actually working! I copied it into this plunkr and it's just right (beware that pl is the last one inside the selection list since we add it in the js code after the library got instantiated).

    Note that I had to remove the curly bracket under the line:

    ... definitions of translation goes here