From f476b6e476a8d379019b588a96bf861ce000982a Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Fri, 11 Jul 2025 20:43:09 -0400 Subject: [PATCH] disable URL conversion during chunking and add debug logging for chunk content --- src/translation.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/translation.js b/src/translation.js index 4dc2985..341e7d6 100644 --- a/src/translation.js +++ b/src/translation.js @@ -500,12 +500,10 @@ export async function translateHTML(htmlContent, targetLanguage, sourceUrl = nul throw new Error("Unable to extract meaningful content from provided HTML."); } - // Convert relative URLs to absolute if sourceUrl is provided + // Skip URL conversion during chunking to avoid performance overhead + // We'll add base tag instead which is more efficient let processedContent = htmlContent; - if (sourceUrl) { - processedContent = convertRelativeToAbsolute(htmlContent, sourceUrl); - console.log('Converted relative URLs using base URL:', sourceUrl); - } + console.log('Skipping URL conversion for chunked translation - will use base tag instead'); // Use actual token limits instead of character limits const maxTokens = getSelectedModelMaxTokens(); @@ -528,6 +526,11 @@ export async function translateHTML(htmlContent, targetLanguage, sourceUrl = nul const chunks = await splitHTMLIntoChunks(processedContent, availableTokens, getSelectedModel()); console.log(`Split into ${chunks.length} chunks for parallel translation`); + // Debug: log chunk content to see what we're actually translating + chunks.forEach((chunk, index) => { + console.log(`Chunk ${index + 1} preview:`, chunk.substring(0, 200) + (chunk.length > 200 ? '...' : '')); + }); + // Translate all chunks in parallel using the normal translateText function const translationPromises = chunks.map((chunk, index) => { console.log(`Queued chunk ${index + 1}/${chunks.length} for translation`);