Skip to content

Commit

Permalink
Find new expressions when looking for translation functions (#6)
Browse files Browse the repository at this point in the history
Needed for matrix-org/matrix-react-sdk#10440
```
new UserFriendlyError("This email address is already in use" , { cause: err });
```
  • Loading branch information
MadLittleMods authored Mar 24, 2023
1 parent a87fd27 commit 8027824
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scripts/gen-i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
isTemplateLiteral,
isIdentifier,
isCallExpression,
isNewExpression,
isObjectProperty,
isObjectExpression,
ObjectExpression,
Expand Down Expand Up @@ -151,7 +152,11 @@ function getTranslationsJs(file: string): Set<string> {
});
traverse(babelParsed, {
enter: (p) => {
if (isCallExpression(p.node) && isIdentifier(p.node.callee) && TRANSLATIONS_FUNCS.includes(p.node.callee.name)) {
if (
(isNewExpression(p.node) || isCallExpression(p.node)) &&
isIdentifier(p.node.callee) &&
TRANSLATIONS_FUNCS.includes(p.node.callee.name)
) {
const tKey = getTKey(p.node.arguments[0]);

// This happens whenever we call _t with non-literals (ie. whenever we've
Expand Down

0 comments on commit 8027824

Please sign in to comment.