Skip to content

Commit

Permalink
extract-js-i18n: Normalize BinaryExpressions when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Jyrno42 committed Nov 21, 2016
1 parent 846162d commit 8343dfe
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tg_react/management/commands/extract-js-i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,19 @@ const GETTEXT_FUNCS = [
function getNodeValue(node) {
if (node.type === 'StringLiteral') {
return node.value;
} else if (node.type === 'BinaryExpression' &&
node.left.type === 'StringLiteral' && node.right.type === 'StringLiteral') {
return getNodeValue(node.left) + getNodeValue(node.right);
} else if (node.type === 'BinaryExpression') {
if (node.left.type === 'StringLiteral' && node.right.type === 'StringLiteral') {
return getNodeValue(node.left) + getNodeValue(node.right);
} else {
let lNode = getNodeValue(node.left);
let rNode = getNodeValue(node.right);

if (lNode !== null && rNode !== null) {
return lNode + rNode;
} else {
return null;
}
}
} else {
return null;
}
Expand Down

0 comments on commit 8343dfe

Please sign in to comment.