Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion lib/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ var Extractor = (function () {
reference = { file: reference };
}

// Removing translations consist entirely of expression
var expressionRegex = new RegExp('^\\s*?' + this.options.startDelim + '[^\'"' + this.options.endDelim + ']*?' + this.options.endDelim + '\\s*?$');

if (expressionRegex.test(string) && !string.replace(expressionRegex, '').length) {
return;
}

string = string.trim();

if (string.length === 0) {
Expand Down Expand Up @@ -414,7 +421,15 @@ var Extractor = (function () {
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);

// slight hack for <div translate="translate">text</div>
var gotAttr = getAttr(attr);
var isTranslate = attr === 'translate' && gotAttr === 'translate';
if (isTranslate) {
gotAttr = null;
}

self.addString(reference(n.startIndex), gotAttr || str || '', attrValue.plural, attrValue.extractedComment, attrValue.context);
} else if (matches = self.noDelimRegex.exec(getAttr(attr))) {
str = matches[2].replace(/\\\'/g, '\'');
self.addString(reference(n.startIndex), str);
Expand Down
Loading