Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

fix: skip translation key extraction for files without i18n usage (#6221)

Ludy9890d6a7def0
diff --git a/frontend/src/core/tests/missingTranslations.test.ts b/frontend/src/core/tests/missingTranslations.test.ts
index 5806f9e271..fde8b8cfb4 100644
--- a/frontend/src/core/tests/missingTranslations.test.ts
+++ b/frontend/src/core/tests/missingTranslations.test.ts
@@ -21,6 +21,7 @@ const IGNORED_FILE_PATTERNS = [
const IGNORED_KEYS = new Set<string>([
// If the script has found a false-positive that shouldn't be in the translations, include it here
]);
+const LIKELY_TRANSLATION_USAGE_RE = /(?:^|[^\w$])t\s*\(|\.t\s*\(|\bi18nKey\b/;
type FoundKey = {
key: string;
@@ -90,6 +91,10 @@ const getScriptKind = (file: string): ts.ScriptKind => {
*/
const extractKeys = (file: string): FoundKey[] => {
const code = fs.readFileSync(file, "utf8");
+ if (!LIKELY_TRANSLATION_USAGE_RE.test(code)) {
+ return [];
+ }
+
const sourceFile = ts.createSourceFile(
file,
code,