From cc67bf0dcd625aedb0ad7fedf8b59c05c0e4adac Mon Sep 17 00:00:00 2001 From: ShareVB Date: Mon, 23 Mar 2026 21:03:48 +0100 Subject: [PATCH] chore: extract tab attribute in scripts --- scripts/extract-tools-strings.mjs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/extract-tools-strings.mjs b/scripts/extract-tools-strings.mjs index c81916a0..3d6fa093 100644 --- a/scripts/extract-tools-strings.mjs +++ b/scripts/extract-tools-strings.mjs @@ -40,7 +40,7 @@ function processVueComponent(filePath, toolName) { if (!text?.trim()) { return match; } - const key = (attr + '-' + text.replace(/[\p{P}\p{S}\s]+/gu, '-').replace(/^-+|-+$/g, '').replace(/-+/g, '-')).toLowerCase(); + const key = (`${attr}-${text.replace(/[\p{P}\p{S}\s]+/gu, '-').replace(/^-+|-+$/g, '').replace(/-+/g, '-')}`).toLowerCase(); if (!localesData.tools[toolName].texts) { localesData.tools[toolName].texts = {}; } @@ -48,7 +48,7 @@ function processVueComponent(filePath, toolName) { return `${attr}: t('tools.${toolName}.texts.${key}')`; }); - if (content.includes("/* NO EXTRACT SCRIPT */")) { + if (content.includes('/* NO EXTRACT SCRIPT */')) { console.log(`Marked to not extract: ${filePath}`); return; } @@ -63,12 +63,12 @@ function processVueComponent(filePath, toolName) { if (filePath.endsWith('.vue')) { // Regex to find label or placeholder attributes - regex = /(? { if (!text?.trim()) { return match; } - const key = (attr + '-' + text.replace(/[\p{P}\p{S}\s]+/gu, '-').replace(/^-+|-+$/g, '').replace(/-+/g, '-')).toLowerCase(); + const key = (`${attr}-${text.replace(/[\p{P}\p{S}\s]+/gu, '-').replace(/^-+|-+$/g, '').replace(/-+/g, '-')}`).toLowerCase(); if (!localesData.tools[toolName].texts) { localesData.tools[toolName].texts = {}; } @@ -85,7 +85,7 @@ function processVueComponent(filePath, toolName) { if (text.match(/[\}\{\|\[\<\>\]]/)) { return match; } - const key = ('tag-' + text.trim().replace(/[\p{P}\p{S}\s]+/gu, '-').replace(/^-+|-+$/g, '').replace(/-+/g, '-')).toLowerCase(); + const key = (`tag-${text.trim().replace(/[\p{P}\p{S}\s]+/gu, '-').replace(/^-+|-+$/g, '').replace(/-+/g, '-')}`).toLowerCase(); if (!localesData.tools[toolName].texts) { localesData.tools[toolName].texts = {}; } @@ -102,13 +102,13 @@ function processVueComponent(filePath, toolName) { if (filePath.endsWith('.vue')) { // Ensure the useI18n import exists if (!hasAlreayI18n) { - content = content.replace(/\