0

Before I start rewriting my code:

Using angular-gettext, is there anyway to deal with these type of inline ternary condition? Applying the translate filter doesn't seem to be an option here...

<a uib-tooltip="{{favourite?'remove from favourites':'add to favourites'}}" ng-click="someaction()">something</a>

Thanks in advance!

1 Answers1

0

I would just move the strings to the controller (see the ng-gettext docs):

angular.module("someApp").controller("someController", ['gettext', function (gettext) {
    $scope.favoriteRemove = gettext("remove from favorites"),
    $scope.favoriteAdd = gettext("add to favorites");
}]);

HTML

<a uib-tooltip="{{favourite?favoriteRemove:favoriteAdd}}" ng-click="someaction()">something</a>
Constantine Poltyrev
  • 1,015
  • 10
  • 12
  • Yeah, I think your right. I was just hoping there was an inline solution that I had overlooked... or a clever way to use the filter anyway:-) – Raymond Elferink Nov 22 '15 at 23:10
  • I think the filter is not an issue here - it should work once you have the translated strings. But the gettext extractor will get confused by a ternary expression. – Constantine Poltyrev Nov 22 '15 at 23:15