Skip to content

Commit 46fd010

Browse files
committed
Script: Add support for 'display_text' fixture use for default extra fields + better removal of quotes
1 parent c8834ac commit 46fd010

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/scripts/lang/find_missing_terms.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ function extractTermsFromLine(string $line, bool $isVue): array
165165
// trans("term"), ->trans("term"), .trans("term")
166166
preg_match_all('/(?:->|\.)?trans\s*\(\s*(["\'])(.*?)(?<!\\\\)\1\s*\)/x', $line, $matches);
167167
addUnescapedTerms($matches, $terms);
168+
169+
// 'display_text' => 'term',
170+
preg_match_all('/.*\'display_text\'\s\=\>\s(\')(.*?)\'/x', $line, $matches);
171+
addUnescapedTerms($matches, $terms);
168172
}
169173

170174
return $terms;
@@ -194,6 +198,11 @@ function addUnescapedTerms(array $matches, array &$terms): void
194198
} else {
195199
$term = unescape_single($term);
196200
}
201+
$first = substr($term, 0, 1);
202+
$last = substr($term, -1);
203+
if (($first === '"' && $last === '"') || ($first === "'" && $last === "'")) {
204+
$term = substr($term, 1, strlen($term) - 2);
205+
}
197206
$terms[] = $term;
198207
}
199208
}

0 commit comments

Comments
 (0)