Skip to content

Commit b4610eb

Browse files
committed
Merge branch 'wilhelmhb-fix/multiple-translation-functions'
2 parents ec126b0 + 90d0bc8 commit b4610eb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/lexers/javascript-lexer.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,12 @@ export default class JavascriptLexer extends BaseLexer {
194194
).find(([name, translationFunc]) => translationFunc?.pos === node.pos)
195195
let storeGlobally = functionDefinition?.[1].storeGlobally ?? true
196196

197-
if (
198-
this.namespaceFunctions.includes(node.expression.escapedText) &&
199-
node.arguments.length
200-
) {
197+
const isNamespaceFunction =
198+
this.namespaceFunctions.includes(node.expression.escapedText) ||
199+
// Support matching the namespace as well, i.e. match `i18n.useTranslation('ns')`
200+
this.namespaceFunctions.includes(this.expressionToName(node.expression))
201+
202+
if (isNamespaceFunction && node.arguments.length) {
201203
storeGlobally |= node.expression.escapedText === 'withTranslation'
202204
const namespaceArgument = node.arguments[0]
203205
const optionsArgument = node.arguments[1]

0 commit comments

Comments
 (0)