Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom attributes translation extracts inner html instead of attribute value #354

Open
aszczepanek opened this issue May 11, 2018 · 1 comment

Comments

@aszczepanek
Copy link

Configuration:
{ attributes: ["title"] }

Example html:
<div title="Some hint for user"> <div>Header</div> <div>Some content to read</div> < /div>

Current implementation will extract inner html (<div>Header...) instead of title attribute value, probably because of this lines:
if (possibleAttributes.indexOf(attr) > -1) {
var attrValue = extracted[attr];
str = node.html(); // this shouldn't be necessary, but it is
self.addString(reference(n.startIndex), str || getAttr(attr) || '', attrValue.plural, attrValue.extractedComment, attrValue.context);
}

It works only for attributes on elements without closing tag like input:
<input type="text" placeholder="This text can be extracted" title="This text can also be extracted">

There is no tag so node.html() returns nothing so getAttr can execute.

@dakk
Copy link

dakk commented Jun 14, 2018

@aszczepanek did you fixed this problem without angular-gettext modifications?

I found that substituting this:

self.addString(reference(n.startIndex), str || getAttr(attr) || '', attrValue.plural, attrValue.extractedComment, attrValue.context);

With this:

self.addString(reference(n.startIndex), getAttr(attr) || str || '', attrValue.plural, attrValue.extractedComment, attrValue.context);

Solves the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants