Legal Language Translation Compliance Checker

Legal Language Translation Compliance Checker

Analyze translated legal documents for key term consistency and complexity.

Original & Translated Documents

Please provide both original and translated text in Tab 1.

`; downloadBtnContainer.classList.add('hidden'); return; } const keywords = keywordsRaw ? keywordsRaw.split(',').filter(k => k.trim() !== '') : []; // Perform analyses const originalStats = getTextStats(originalText); const translatedStats = getTextStats(translatedText); const originalFlesch = calculateFleschReadingEase(originalStats); const translatedFlesch = calculateFleschReadingEase(translatedStats); const keywordResults = checkKeywordCompliance(translatedText, keywords); const keywordsFound = keywordResults.filter(r => r.found).length; const totalKeywords = keywordResults.length; const keywordCompliance = totalKeywords > 0 ? ((keywordsFound / totalKeywords) * 100).toFixed(0) : 100; reportData = { originalStats, translatedStats, originalFlesch, translatedFlesch, keywordResults, keywordCompliance }; // Store for PDF // Build report HTML let keywordHtml = keywords.length > 0 ? `

Keyword Compliance (${keywordCompliance}%)

    ${keywordResults.map(r => `
  • ${r.keyword} ${r.found ? ` Found` : ` Missing` }
  • `).join('')}
` : '

No keywords were specified for checking.

'; const reportHtml = `
${keywordHtml}

Original Text Analysis

  • Word Count: ${originalStats.wordCount}
  • Sentence Count: ${originalStats.sentenceCount}
  • Readability Score: ${originalFlesch}
  • Interpretation: ${interpretFleschScore(originalFlesch)}

Translated Text Analysis

  • Word Count: ${translatedStats.wordCount}
  • Sentence Count: ${translatedStats.sentenceCount}
  • Readability Score: ${translatedFlesch}
  • Interpretation: ${interpretFleschScore(translatedFlesch)}
`; reportContainer.innerHTML = reportHtml; downloadBtnContainer.classList.remove('hidden'); lucide.createIcons(); }; // --- UI & NAVIGATION --- const updateNavButtons = () => { prevBtn.disabled = currentTab === '1'; nextBtn.disabled = currentTab === '3'; prevBtn.classList.toggle('opacity-50', prevBtn.disabled); nextBtn.classList.toggle('opacity-50', nextBtn.disabled); }; window.switchTab = (tabId) => { currentTab = tabId; if (currentTab === '3') { generateAndDisplayReport(); } tabs.forEach(id => { document.getElementById(`tab-content-${id}`).classList.toggle('hidden', id !== currentTab); document.getElementById(`tab-btn-${id}`).classList.toggle('tab-active', id === currentTab); document.getElementById(`tab-btn-${id}`).classList.toggle('tab-inactive', id !== currentTab); }); updateNavButtons(); }; const navigateTabs = (direction) => { const currentIndex = tabs.indexOf(currentTab); let nextIndex = currentIndex + direction; if (nextIndex >= 0 && nextIndex < tabs.length) { switchTab(tabs[nextIndex]); } }; // --- PDF GENERATION --- downloadPdfBtn.addEventListener('click', () => { if (!reportData) return; const { jsPDF } = window.jspdf; const doc = new jsPDF(); doc.setFontSize(18); doc.text("Legal Translation Compliance Report", 14, 22); doc.setFontSize(11); doc.setTextColor(100); doc.text(`Report generated on: ${new Date().toLocaleDateString()}`, 14, 30); // Keyword Table if (reportData.keywordResults.length > 0) { doc.autoTable({ head: [['Required Keyword', 'Status']], body: reportData.keywordResults.map(r => [r.keyword, r.found ? 'Found' : 'Missing']), startY: 40, theme: 'grid', headStyles: { fillColor: [45, 102, 193] }, didParseCell: function(data) { if (data.section === 'body' && data.column.index === 1) { if (data.cell.raw === 'Found') { data.cell.styles.textColor = [22, 163, 74]; } else { data.cell.styles.textColor = [220, 38, 38]; } } } }); } // Analysis Table const analysisBody = [ ['Word Count', reportData.originalStats.wordCount, reportData.translatedStats.wordCount], ['Sentence Count', reportData.originalStats.sentenceCount, reportData.translatedStats.sentenceCount], ['Readability Score', reportData.originalFlesch, reportData.translatedFlesch], ['Interpretation', interpretFleschScore(reportData.originalFlesch), interpretFleschScore(reportData.translatedFlesch)], ]; doc.autoTable({ head: [['Metric', 'Original Text', 'Translated Text']], body: analysisBody, startY: doc.previousAutoTable ? doc.previousAutoTable.finalY + 10 : 40, theme: 'grid', headStyles: { fillColor: [45, 102, 193] }, }); doc.save('Translation_Compliance_Report.pdf'); }); // --- INITIALIZATION --- updateNavButtons(); lucide.createIcons(); prevBtn.addEventListener('click', () => navigateTabs(-1)); nextBtn.addEventListener('click', () => navigateTabs(1)); });
Scroll to Top