rubenv / angular-gettext-tools

Tools for extracting/compiling angular-gettext strings.
http://angular-gettext.rocketeer.be/
MIT License
39 stars 129 forks source link

prioritize attribute extraction over html content. #120

Closed anilanar closed 6 years ago

anilanar commented 8 years ago

A quick fix based on my question in the main repo: https://github.com/rubenv/angular-gettext/issues/246

Assuming we have tooltip attribute added into grunt config options.attributes:

<!-- Extracts "text1" -->
<x tooltip="text1"></x>

<!-- Extracts "text1" -->
<x tooltip="text1">text2</x>

<!-- Extracts "text1" and "text2" -->
<x tooltip="text1" translate>text2</x>

And we can combine attr-n, attr-plural, attr-context and attr-comment with translate, but it is not related to this fix:

<x tooltip-n="personCount" tooltip-plural="{{$tooltipCount}} people" tooltip="1 person" 
     translate-n="penCount" translate-plural="{{$count}} pens"> 1 pen
</x>

As you can see, I have used $tooltipCount instead of $count for tooltip attribute because they use the same scope and those properties of scope would override each other's value if they had the same name. Also this example assumes someone created a custom directive for tooltip attribute.

anilanar commented 8 years ago

Based on failing test:

If we want <x translate="text1">text2</x> to extract "text2" instead of "text1", the code can be modified further to disallow it. It's a simple if-else statement.

jgaver commented 8 years ago

Has there been any more work on this issue? We are running into the same problem when trying to translate placeholders on nodes that have html content.

karelbilek commented 8 years ago

I think I fixed it here

https://github.com/rubenv/angular-gettext-tools/pull/147

anilanar commented 8 years ago

@runn1ng Hey thanks, but repo owner has not answered yet.

Narretz commented 8 years ago

It helps to include a test for the behavior you want to fix