jsxgettext
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -24,2 +24,16 @@ #!/usr/bin/env node | ||
function checkExpr(node, keyword) { | ||
return (node.type === "CallExpression" && // must be a call expression | ||
( | ||
(node.callee.name === 'gettext' || // with a gettext call expr | ||
(node.callee.name === keyword)) // or keyword call expr | ||
|| | ||
(node.callee.type === 'MemberExpression' && // or a member expr | ||
(node.callee.property.name === 'gettext' || | ||
node.callee.property.name === keyword)) | ||
) | ||
&& | ||
typeof node.arguments[0].value === 'string') // must have a string argument | ||
} | ||
// generate extracted strings file | ||
@@ -37,7 +51,3 @@ function gen (sources, options) { | ||
enter: function (node) { | ||
if (node.type === "CallExpression" && // must be a call expression | ||
(node.callee.name === 'gettext' || // must be a gettext call | ||
(options.keyword && node.callee.name === options.keyword)) && // or a specified keyword call | ||
typeof node.arguments[0].value === 'string' // must have a string argument | ||
) { | ||
if (checkExpr(node, options.keyword)) { | ||
var str = node.arguments[0].value; | ||
@@ -44,0 +54,0 @@ var line = node.loc.start.line; |
@@ -5,3 +5,3 @@ { | ||
"description": "Extract gettext calls from JavaScript and EJS files", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -12,2 +12,3 @@ // TODO figure out why | ||
exports.testAll['test comments'] = require('./test_comment'); | ||
exports.testAll['test expressiosn'] = require('./expressions'); | ||
@@ -14,0 +15,0 @@ if (module == require.main) { |
48469
30
737
9