diff --git a/scripts/extract-tools-desc.mjs b/scripts/extract-tools-desc.mjs index 1e26639a..f61c0290 100644 --- a/scripts/extract-tools-desc.mjs +++ b/scripts/extract-tools-desc.mjs @@ -29,10 +29,10 @@ function processFile(filePath) { // Modify name and description to use the translate function const transformedContent = originalContent - .replace(/name: '((?:[^']+|(?<=\\)')+)'/, `name: translate('tools.${parentDir}.title')`) - .replace(/description: '((?:[^']+|(?<=\\)')+)'/, `description: translate('tools.${parentDir}.description')`); + .replace(/name: '((?:[^']+|(?<=\\)')+)'/, `name: t('tools.${parentDir}.title')`) + .replace(/description: '((?:[^']+|(?<=\\)')+)'/, `description: t('tools.${parentDir}.description')`); - fs.writeFileSync(filePath, `import { translate } from '@/plugins/i18n.plugin';\n${transformedContent}`, 'utf-8'); + fs.writeFileSync(filePath, `import { translate as t } from '@/plugins/i18n.plugin';\n${transformedContent}`, 'utf-8'); console.log(`Transformed: ${filePath}`); // Update locales file with extracted name and description diff --git a/scripts/extract-tools-strings.mjs b/scripts/extract-tools-strings.mjs index e07d5faa..9d2e4b52 100644 --- a/scripts/extract-tools-strings.mjs +++ b/scripts/extract-tools-strings.mjs @@ -21,6 +21,8 @@ function processVueComponents(toolDir, toolName) { // Function to process a Vue component file function processVueComponent(filePath, toolName) { + console.log(`Processing ${filePath} in ${toolName}`); + let content = fs.readFileSync(filePath, 'utf8'); const origContent = content; @@ -83,17 +85,38 @@ function processVueComponent(filePath, toolName) { console.log(`Nothing to extract in ${filePath}`); return; } - // Ensure the useI18n import exists - if (!content.includes("const { t } = useI18n();")) { - content = content.replace(/\