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

Fix value priority order for custom translation attribute extraction

Open bartbutler opened this issue 8 years ago • 4 comments

When using a custom directive on an attribute, the extracted string should default to the value of the attribute, and if not present, fallback to the HTML inside the tag. For example, if I want to translate all my 'tooltip' attributes, and have some HTML like this:

<span tooltip="translate this">Not this</span>

The old extract.js would extract "Not this" instead. This change fixes this, while allowing "Not this" to be translated if desired by giving the attribute no value.

bartbutler avatar Apr 11 '16 00:04 bartbutler

Whoops, this is a repeat of #120, though perhaps slightly cleaner. Sorry.

bartbutler avatar Apr 11 '16 00:04 bartbutler

@rubenv, forgive my ignorance, but the tests that fail here seem to be broken. For instance, there is stuff like this:

<h4 translate="translate">Translate this</h4>

From the current documentation (and logic) I would expect that if the user wanted to translate 'Translate this' they would use:

<h4 translate>Translate this</h4>

bartbutler avatar Apr 11 '16 00:04 bartbutler

Made a special case for attribute translate = "translate", as I imagine there are existing codebases using this syntax.

bartbutler avatar Apr 11 '16 05:04 bartbutler

You should include a test for this change. Then maybe it gets attention from @rubenv

Narretz avatar Aug 03 '16 12:08 Narretz