mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-14 10:34:06 +02:00
fix: skip translation key extraction for files without i18n usage (#6221)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user