angular-gettext icon indicating copy to clipboard operation
angular-gettext copied to clipboard

extract html attribute

Open f0x11 opened this issue 7 years ago • 2 comments

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?

f0x11 avatar Jul 31 '17 11:07 f0x11

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/

rubenv avatar Jul 31 '17 11:07 rubenv

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

alfaproject avatar Jul 31 '17 18:07 alfaproject