rubenv/angular-gettext

extract html attribute

f0x11 opened this issue · 2 comments

f0x11 commented

I have an attribute,
<a content="{{expand ? 'a.' : 'b.'}}">
I want add a 'translate', then get a pot file contains "a" and "b". How can I do it?

Not ideal, but there's an approach that works:

Put them on the scope and translate from directly.

$scope.a = gettext('a.');
$scope.b = gettext('b.');

The gettext() wrapper is key to annotate the strings for translation.

And somewhere (we put it on the root scope):

$scope.translate = gettextCatalog.getString;

This then becomes:

<a content="{{translate(expand ? a : b)}}">

More info: https://angular-gettext.rocketeer.be/dev-guide/annotate-js/

If you do the scope annotation then you can use the filter on the view btw