From 957cc660a1cb5e8c2093cc0812179102c8166feb Mon Sep 17 00:00:00 2001 From: Florent Detry Date: Thu, 20 Oct 2022 10:22:10 +0200 Subject: [PATCH] Extract isGetString: add option moduleMethodStringArgumentIndex --- README.md | 1 + lib/extract.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 362dbac..164c74d 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ All options and defaults are displayed below: "markerNamesPlural": [], "moduleName": "gettextCatalog", "moduleMethodString": "getString", + "moduleMethodStringArgumentIndex": 0, "moduleMethodPlural": "getPlural", "attribute": "translate", "attributes": [], diff --git a/lib/extract.js b/lib/extract.js index 6ea1e83..4074d04 100644 --- a/lib/extract.js +++ b/lib/extract.js @@ -99,6 +99,7 @@ var Extractor = (function () { markerNamesPlural: [], moduleName: 'gettextCatalog', moduleMethodString: 'getString', + moduleMethodStringArgumentIndex: 0, moduleMethodPlural: 'getPlural', attribute: 'translate', attributes: [], @@ -331,11 +332,16 @@ var Extractor = (function () { })() }; - if (isGettext(node) || isGetString(node)) { + if (isGettext(node)) { str = getJSExpression(node.arguments[0]); if (node.arguments[2]) { context = getJSExpression(node.arguments[2]); } + } else if (isGetString(node)) { + str = getJSExpression(node.arguments[self.options.moduleMethodStringArgumentIndex]); + if (node.arguments[2]) { + context = getJSExpression(node.arguments[2]); + } } else if (isGettextPlural(node) || isGetPlural(node)) { singular = getJSExpression(node.arguments[1]); plural = getJSExpression(node.arguments[2]);