rubenv / angular-gettext-tools

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

Fix value priority order for custom translation attribute extraction #137

Open bartbutler opened 8 years ago

bartbutler commented 8 years ago

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 commented 8 years ago

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

bartbutler commented 8 years ago

@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 commented 8 years ago

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

Narretz commented 8 years ago

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