diff --git a/public/locales/de/common.json b/public/locales/de/common.json index 4d749a0..3c342e8 100644 --- a/public/locales/de/common.json +++ b/public/locales/de/common.json @@ -250,11 +250,13 @@ "add": "Hinzufügen", "remove": "Entfernen", "loading": "Laden...", + "loadingPageCount": "Seitenanzahl wird geladen...", "error": "Fehler", "success": "Erfolgreich", "file": "Datei", "files": "Dateien", - "close": "Schließen" + "close": "Schließen", + "convert": "Konvertieren" }, "about": { "hero": { diff --git a/public/locales/de/tools.json b/public/locales/de/tools.json index 402aa12..ca05f8a 100644 --- a/public/locales/de/tools.json +++ b/public/locales/de/tools.json @@ -263,23 +263,84 @@ }, "pdfToJpg": { "name": "PDF zu JPG", - "subtitle": "Jede PDF-Seite in ein JPG-Bild konvertieren." + "subtitle": "Jede PDF-Seite in ein JPG-Bild konvertieren.", + "imageQuality": "Bildqualität", + "imageQualityExplanation": "Höhere Qualität = größere Dateigröße", + "alert": { + "invalidFile": "Ungültige Datei", + "invalidFileExplanation": "Bitte wähle eine PDF Datei aus.", + "noFile": "Keine Datei", + "noFileExplanation": "Bitte lade zuerst eine PDF-Datei hoch.", + "conversionSuccess": "PDF erfolgreich in JPGs konvertiert!", + "conversionError": "Konvertierung in JPG fehlgeschlagen. Die Datei könnte beschädigt sein." + }, + "loader": { + "converting": "Wird in JPG konvertiert..." + } }, "pdfToPng": { "name": "PDF zu PNG", - "subtitle": "Jede PDF-Seite in ein PNG-Bild konvertieren." + "subtitle": "Jede PDF-Seite in ein PNG-Bild konvertieren.", + "imageScale": "Bildskalierung", + "imageScaleExplanation": "Höhere Skalierung = bessere Qualität, aber größere Dateigröße", + "alert": { + "invalidFile": "Ungültige Datei", + "invalidFileExplanation": "Bitte wähle eine PDF Datei aus.", + "noFile": "Keine Datei", + "noFileExplanation": "Bitte lade zuerst eine PDF-Datei hoch.", + "conversionSuccess": "PDF erfolgreich in PNGs konvertiert!", + "conversionError": "Konvertierung in PNG fehlgeschlagen. Die Datei könnte beschädigt sein." + }, + "loader": { + "converting": "Wird in PNG konvertiert..." + } }, "pdfToWebp": { "name": "PDF zu WebP", - "subtitle": "Jede PDF-Seite in ein WebP-Bild konvertieren." + "subtitle": "Jede PDF-Seite in ein WebP-Bild konvertieren.", + "imageQuality": "Bildqualität", + "imageQualityExplanation": "Höhere Qualität = größere Dateigröße", + "alert": { + "invalidFile": "Ungültige Datei", + "invalidFileExplanation": "Bitte wähle eine PDF Datei aus.", + "noFile": "Keine Datei", + "noFileExplanation": "Bitte lade zuerst eine PDF-Datei hoch.", + "conversionSuccess": "PDF erfolgreich in WebPs konvertiert!", + "conversionError": "Konvertierung in WebP fehlgeschlagen. Die Datei könnte beschädigt sein." + }, + "loader": { + "converting": "Wird in WebP konvertiert..." + } }, "pdfToBmp": { "name": "PDF zu BMP", - "subtitle": "Jede PDF-Seite in ein BMP-Bild konvertieren." + "subtitle": "Jede PDF-Seite in ein BMP-Bild konvertieren.", + "alert": { + "invalidFile": "Ungültige Datei", + "invalidFileExplanation": "Bitte wähle eine PDF Datei aus.", + "noFile": "Keine Datei", + "noFileExplanation": "Bitte lade zuerst eine PDF-Datei hoch.", + "conversionSuccess": "PDF erfolgreich in BMPs konvertiert!", + "conversionError": "Konvertierung in BMP fehlgeschlagen. Die Datei könnte beschädigt sein." + }, + "loader": { + "converting": "Wird in BMP konvertiert..." + } }, "pdfToTiff": { "name": "PDF zu TIFF", - "subtitle": "Jede PDF-Seite in ein TIFF-Bild konvertieren." + "subtitle": "Jede PDF-Seite in ein TIFF-Bild konvertieren.", + "alert": { + "invalidFile": "Ungültige Datei", + "invalidFileExplanation": "Bitte wähle eine PDF Datei aus.", + "noFile": "Keine Datei", + "noFileExplanation": "Bitte lade zuerst eine PDF-Datei hoch.", + "conversionSuccess": "PDF erfolgreich in TIFFs konvertiert!", + "conversionError": "Konvertierung in TIFF fehlgeschlagen. Die Datei könnte beschädigt sein." + }, + "loader": { + "converting": "Wird in TIFF konvertiert..." + } }, "pdfToGreyscale": { "name": "PDF zu Graustufen", diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 475ee64..c66aebd 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -260,11 +260,13 @@ "add": "Add", "remove": "Remove", "loading": "Loading...", + "loadingPageCount": "Loading pages...", "error": "Error", "success": "Success", "file": "File", "files": "Files", - "close": "Close" + "close": "Close", + "convert": "Convert" }, "about": { "hero": { diff --git a/public/locales/en/tools.json b/public/locales/en/tools.json index 3fd9e8e..097bb96 100644 --- a/public/locales/en/tools.json +++ b/public/locales/en/tools.json @@ -263,23 +263,84 @@ }, "pdfToJpg": { "name": "PDF to JPG", - "subtitle": "Convert each PDF page into a JPG image." + "subtitle": "Convert each PDF page into a JPG image.", + "imageQuality": "Image Quality", + "imageQualityExplanation": "Higher quality = larger file size", + "alert": { + "invalidFile": "Invalid File", + "invalidFileExplanation": "Please upload a PDF file.", + "noFile": "No File", + "noFileExplanation": "Please upload a PDF file first.", + "conversionSuccess": "PDF converted to JPGs successfully!", + "conversionError": "Failed to convert PDF to JPG. The file might be corrupted." + }, + "loader": { + "converting": "Converting to JPG..." + } }, "pdfToPng": { "name": "PDF to PNG", - "subtitle": "Convert each PDF page into a PNG image." + "subtitle": "Convert each PDF page into a PNG image.", + "imageScale": "Image Scale", + "imageScaleExplanation": "Higher scale = better quality but larger file size", + "alert": { + "invalidFile": "Invalid File", + "invalidFileExplanation": "Please upload a PDF file.", + "noFile": "No File", + "noFileExplanation": "Please upload a PDF file first.", + "conversionSuccess": "PDF converted to PNGs successfully!", + "conversionError": "Failed to convert PDF to PNG. The file might be corrupted." + }, + "loader": { + "converting": "Converting to PNG..." + } }, "pdfToWebp": { "name": "PDF to WebP", - "subtitle": "Convert each PDF page into a WebP image." + "subtitle": "Convert each PDF page into a WebP image.", + "imageQuality": "Image Quality", + "imageQualityExplanation": "Higher quality = larger file size", + "alert": { + "invalidFile": "Invalid File", + "invalidFileExplanation": "Please upload a PDF file.", + "noFile": "No File", + "noFileExplanation": "Please upload a PDF file first.", + "conversionSuccess": "PDF converted to WebPs successfully!", + "conversionError": "Failed to convert PDF to WebP. The file might be corrupted." + }, + "loader": { + "converting": "Converting to WebP..." + } }, "pdfToBmp": { "name": "PDF to BMP", - "subtitle": "Convert each PDF page into a BMP image." + "subtitle": "Convert each PDF page into a BMP image.", + "alert": { + "invalidFile": "Invalid File", + "invalidFileExplanation": "Please upload a PDF file.", + "noFile": "No File", + "noFileExplanation": "Please upload a PDF file first.", + "conversionSuccess": "PDF converted to BMPs successfully!", + "conversionError": "Failed to convert PDF to BMP. The file might be corrupted." + }, + "loader": { + "converting": "Converting to BMP..." + } }, "pdfToTiff": { "name": "PDF to TIFF", - "subtitle": "Convert each PDF page into a TIFF image." + "subtitle": "Convert each PDF page into a TIFF image.", + "alert": { + "invalidFile": "Invalid File", + "invalidFileExplanation": "Please upload a PDF file.", + "noFile": "No File", + "noFileExplanation": "Please upload a PDF file first.", + "conversionSuccess": "PDF converted to TIFFs successfully!", + "conversionError": "Failed to convert PDF to TIFF. The file might be corrupted." + }, + "loader": { + "converting": "Converting to TIFF..." + } }, "pdfToGreyscale": { "name": "PDF to Greyscale", diff --git a/src/js/logic/adjust-colors-page.ts b/src/js/logic/adjust-colors-page.ts index 59ece2d..e46d4b1 100644 --- a/src/js/logic/adjust-colors-page.ts +++ b/src/js/logic/adjust-colors-page.ts @@ -10,6 +10,7 @@ import { PDFDocument } from 'pdf-lib'; import { applyColorAdjustments } from '../utils/image-effects.js'; import * as pdfjsLib from 'pdfjs-dist'; import type { AdjustColorsSettings } from '../types/adjust-colors-type.js'; +import { t } from '../i18n/i18n'; pdfjsLib.GlobalWorkerOptions.workerSrc = new URL( 'pdfjs-dist/build/pdf.worker.min.mjs', @@ -123,7 +124,7 @@ const updateUI = () => { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(file.size)} • Loading pages...`; + metaSpan.textContent = `${formatBytes(file.size)} • ${t('common.loadingPageCount')}`; infoContainer.append(nameSpan, metaSpan); @@ -146,7 +147,7 @@ const updateUI = () => { return getPDFDocument(buffer).promise; }) .then((pdf: pdfjsLib.PDFDocumentProxy) => { - metaSpan.textContent = `${formatBytes(file.size)} • ${pdf.numPages} page${pdf.numPages !== 1 ? 's' : ''}`; + metaSpan.textContent = `${formatBytes(file.size)} • ${pdf.numPages} ${pdf.numPages !== 1 ? t('common.pages') : t('common.page')}`; }) .catch(() => { metaSpan.textContent = formatBytes(file.size); diff --git a/src/js/logic/digital-sign-pdf-page.ts b/src/js/logic/digital-sign-pdf-page.ts index 306b22a..1b2d607 100644 --- a/src/js/logic/digital-sign-pdf-page.ts +++ b/src/js/logic/digital-sign-pdf-page.ts @@ -1,6 +1,7 @@ import { createIcons, icons } from 'lucide'; import { showAlert, showLoader, hideLoader } from '../ui.js'; import { readFileAsArrayBuffer, formatBytes, downloadFile, getPDFDocument } from '../utils/helpers.js'; +import { t } from '../i18n/i18n'; import { signPdf, parsePfxFile, @@ -253,7 +254,7 @@ async function updatePdfDisplay(): Promise { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(state.pdfFile.size)} • Loading pages...`; + metaSpan.textContent = `${formatBytes(state.pdfFile.size)} • ${t('common.loadingPageCount')}`; infoContainer.append(nameSpan, metaSpan); diff --git a/src/js/logic/extract-images-page.ts b/src/js/logic/extract-images-page.ts index 36d7f0b..aaab5d1 100644 --- a/src/js/logic/extract-images-page.ts +++ b/src/js/logic/extract-images-page.ts @@ -1,4 +1,5 @@ import { showLoader, hideLoader, showAlert } from '../ui.js'; +import { t } from '../i18n/i18n'; import { downloadFile, readFileAsArrayBuffer, @@ -66,7 +67,7 @@ document.addEventListener('DOMContentLoaded', () => { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(file.size)} • Loading pages...`; + metaSpan.textContent = `${formatBytes(file.size)} • ${t('common.loadingPageCount')}`; infoContainer.append(nameSpan, metaSpan); diff --git a/src/js/logic/pdf-layers-page.ts b/src/js/logic/pdf-layers-page.ts index 22ea415..e1a3836 100644 --- a/src/js/logic/pdf-layers-page.ts +++ b/src/js/logic/pdf-layers-page.ts @@ -1,4 +1,5 @@ import { showLoader, hideLoader, showAlert } from '../ui.js'; +import { t } from '../i18n/i18n'; import { downloadFile, readFileAsArrayBuffer, @@ -60,7 +61,7 @@ document.addEventListener('DOMContentLoaded', () => { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(currentFile.size)} • Loading pages...`; + metaSpan.textContent = `${formatBytes(currentFile.size)} • ${t('common.loadingPageCount')}`; infoContainer.append(nameSpan, metaSpan); diff --git a/src/js/logic/pdf-to-bmp-page.ts b/src/js/logic/pdf-to-bmp-page.ts index 1f71b77..046eea6 100644 --- a/src/js/logic/pdf-to-bmp-page.ts +++ b/src/js/logic/pdf-to-bmp-page.ts @@ -10,6 +10,7 @@ import { createIcons, icons } from 'lucide'; import JSZip from 'jszip'; import * as pdfjsLib from 'pdfjs-dist'; import { PDFPageProxy } from 'pdfjs-dist'; +import { t } from '../i18n/i18n'; pdfjsLib.GlobalWorkerOptions.workerSrc = new URL( 'pdfjs-dist/build/pdf.worker.min.mjs', @@ -44,7 +45,7 @@ const updateUI = () => { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(file.size)} • Loading pages...`; // Initial state + metaSpan.textContent = `${formatBytes(file.size)} • ${t('common.loadingPageCount')}`; // Initial state infoContainer.append(nameSpan, metaSpan); @@ -67,7 +68,7 @@ const updateUI = () => { return getPDFDocument(buffer).promise; }) .then((pdf) => { - metaSpan.textContent = `${formatBytes(file.size)} • ${pdf.numPages} page${pdf.numPages !== 1 ? 's' : ''}`; + metaSpan.textContent = `${formatBytes(file.size)} • ${pdf.numPages} ${pdf.numPages !== 1 ? t('common.pages') : t('common.page')}`; }) .catch((e) => { console.warn('Error loading PDF page count:', e); @@ -91,10 +92,13 @@ const resetState = () => { async function convert() { if (files.length === 0) { - showAlert('No File', 'Please upload a PDF file first.'); + showAlert( + t('tools:pdfToBmp.alert.noFile'), + t('tools:pdfToBmp.alert.noFileExplanation') + ); return; } - showLoader('Converting to BMP...'); + showLoader(t('tools:pdfToBmp.loader.converting')); try { const pdf = await getPDFDocument(await readFileAsArrayBuffer(files[0])) .promise; @@ -118,8 +122,8 @@ async function convert() { } showAlert( - 'Success', - 'PDF converted to BMPs successfully!', + t('common.success'), + t('tools:pdfToBmp.alert.conversionSuccess'), 'success', () => { resetState(); @@ -127,10 +131,7 @@ async function convert() { ); } catch (e) { console.error(e); - showAlert( - 'Error', - 'Failed to convert PDF to BMP. The file might be corrupted.' - ); + showAlert(t('common.error'), t('tools:pdfToBmp.alert.conversionError')); } finally { hideLoader(); } @@ -174,7 +175,10 @@ document.addEventListener('DOMContentLoaded', () => { ); if (validFiles.length === 0) { - showAlert('Invalid File', 'Please upload a PDF file.'); + showAlert( + t('tools:pdfToBmp.alert.invalidFile'), + t('tools:pdfToBmp.alert.invalidFileExplanation') + ); return; } diff --git a/src/js/logic/pdf-to-docx-page.ts b/src/js/logic/pdf-to-docx-page.ts index 3850fbc..101f748 100644 --- a/src/js/logic/pdf-to-docx-page.ts +++ b/src/js/logic/pdf-to-docx-page.ts @@ -1,4 +1,5 @@ import { showLoader, hideLoader, showAlert } from '../ui.js'; +import { t } from '../i18n/i18n'; import { downloadFile, readFileAsArrayBuffer, @@ -50,7 +51,7 @@ document.addEventListener('DOMContentLoaded', () => { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(file.size)} • Loading pages...`; + metaSpan.textContent = `${formatBytes(file.size)} • ${t('common.loadingPageCount')}`; infoContainer.append(nameSpan, metaSpan); diff --git a/src/js/logic/pdf-to-greyscale-page.ts b/src/js/logic/pdf-to-greyscale-page.ts index 64c8df5..c1e7546 100644 --- a/src/js/logic/pdf-to-greyscale-page.ts +++ b/src/js/logic/pdf-to-greyscale-page.ts @@ -9,6 +9,7 @@ import { createIcons, icons } from 'lucide'; import { PDFDocument } from 'pdf-lib'; import { applyGreyscale } from '../utils/image-effects.js'; import * as pdfjsLib from 'pdfjs-dist'; +import { t } from '../i18n/i18n'; pdfjsLib.GlobalWorkerOptions.workerSrc = new URL( 'pdfjs-dist/build/pdf.worker.min.mjs', @@ -44,7 +45,7 @@ const updateUI = () => { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(file.size)} • Loading pages...`; // Initial state + metaSpan.textContent = `${formatBytes(file.size)} • ${t('common.loadingPageCount')}`; // Initial state infoContainer.append(nameSpan, metaSpan); @@ -66,7 +67,7 @@ const updateUI = () => { return getPDFDocument(buffer).promise; }) .then((pdf) => { - metaSpan.textContent = `${formatBytes(file.size)} • ${pdf.numPages} page${pdf.numPages !== 1 ? 's' : ''}`; + metaSpan.textContent = `${formatBytes(file.size)} • ${pdf.numPages} ${pdf.numPages !== 1 ? t('common.pages') : t('common.page')}`; }) .catch((e) => { console.warn('Error loading PDF page count:', e); diff --git a/src/js/logic/pdf-to-jpg-page.ts b/src/js/logic/pdf-to-jpg-page.ts index dc43566..945d022 100644 --- a/src/js/logic/pdf-to-jpg-page.ts +++ b/src/js/logic/pdf-to-jpg-page.ts @@ -10,6 +10,7 @@ import { createIcons, icons } from 'lucide'; import JSZip from 'jszip'; import * as pdfjsLib from 'pdfjs-dist'; import { PDFPageProxy } from 'pdfjs-dist'; +import { t } from '../i18n/i18n'; pdfjsLib.GlobalWorkerOptions.workerSrc = new URL( 'pdfjs-dist/build/pdf.worker.min.mjs', @@ -44,7 +45,7 @@ const updateUI = () => { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(file.size)} • Loading pages...`; // Initial state + metaSpan.textContent = `${formatBytes(file.size)} • ${t('common.loadingPageCount')}`; // Initial state infoContainer.append(nameSpan, metaSpan); @@ -66,7 +67,7 @@ const updateUI = () => { return getPDFDocument(buffer).promise; }) .then((pdf) => { - metaSpan.textContent = `${formatBytes(file.size)} • ${pdf.numPages} page${pdf.numPages !== 1 ? 's' : ''}`; + metaSpan.textContent = `${formatBytes(file.size)} • ${pdf.numPages} ${pdf.numPages !== 1 ? t('common.pages') : t('common.page')}`; }) .catch((e) => { console.warn('Error loading PDF page count:', e); @@ -96,10 +97,13 @@ const resetState = () => { async function convert() { if (files.length === 0) { - showAlert('No File', 'Please upload a PDF file first.'); + showAlert( + t('tools:pdfToJpg.alert.noFile'), + t('tools:pdfToJpg.alert.noFileExplanation') + ); return; } - showLoader('Converting to JPG...'); + showLoader(t('tools:pdfToJpg.loader.converting')); try { const pdf = await getPDFDocument(await readFileAsArrayBuffer(files[0])) .promise; @@ -128,8 +132,8 @@ async function convert() { } showAlert( - 'Success', - 'PDF converted to JPGs successfully!', + t('common.success'), + t('tools:pdfToJpg.alert.conversionSuccess'), 'success', () => { resetState(); @@ -137,10 +141,7 @@ async function convert() { ); } catch (e) { console.error(e); - showAlert( - 'Error', - 'Failed to convert PDF to JPG. The file might be corrupted.' - ); + showAlert(t('common.error'), t('tools:pdfToJpg.alert.conversionError')); } finally { hideLoader(); } @@ -197,7 +198,10 @@ document.addEventListener('DOMContentLoaded', () => { ); if (validFiles.length === 0) { - showAlert('Invalid File', 'Please upload a PDF file.'); + showAlert( + t('tools:pdfToJpg.alert.invalidFile'), + t('tools:pdfToJpg.alert.invalidFileExplanation') + ); return; } diff --git a/src/js/logic/pdf-to-markdown-page.ts b/src/js/logic/pdf-to-markdown-page.ts index f99294b..17143c0 100644 --- a/src/js/logic/pdf-to-markdown-page.ts +++ b/src/js/logic/pdf-to-markdown-page.ts @@ -1,4 +1,5 @@ import { showLoader, hideLoader, showAlert } from '../ui.js'; +import { t } from '../i18n/i18n'; import { downloadFile, readFileAsArrayBuffer, @@ -53,7 +54,7 @@ document.addEventListener('DOMContentLoaded', () => { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(file.size)} • Loading pages...`; + metaSpan.textContent = `${formatBytes(file.size)} • ${t('common.loadingPageCount')}`; infoContainer.append(nameSpan, metaSpan); diff --git a/src/js/logic/pdf-to-pdfa-page.ts b/src/js/logic/pdf-to-pdfa-page.ts index 0de4073..07b3a7d 100644 --- a/src/js/logic/pdf-to-pdfa-page.ts +++ b/src/js/logic/pdf-to-pdfa-page.ts @@ -1,4 +1,5 @@ import { showLoader, hideLoader, showAlert } from '../ui.js'; +import { t } from '../i18n/i18n'; import { downloadFile, readFileAsArrayBuffer, @@ -53,7 +54,7 @@ document.addEventListener('DOMContentLoaded', () => { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(file.size)} • Loading pages...`; + metaSpan.textContent = `${formatBytes(file.size)} • ${t('common.loadingPageCount')}`; infoContainer.append(nameSpan, metaSpan); diff --git a/src/js/logic/pdf-to-png-page.ts b/src/js/logic/pdf-to-png-page.ts index 8f4995d..9b33813 100644 --- a/src/js/logic/pdf-to-png-page.ts +++ b/src/js/logic/pdf-to-png-page.ts @@ -10,6 +10,7 @@ import { createIcons, icons } from 'lucide'; import JSZip from 'jszip'; import * as pdfjsLib from 'pdfjs-dist'; import { PDFPageProxy } from 'pdfjs-dist'; +import { t } from '../i18n/i18n'; pdfjsLib.GlobalWorkerOptions.workerSrc = new URL( 'pdfjs-dist/build/pdf.worker.min.mjs', @@ -44,7 +45,7 @@ const updateUI = () => { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(file.size)} • Loading pages...`; // Initial state + metaSpan.textContent = `${formatBytes(file.size)} • ${t('common.loadingPageCount')}`; // Initial state infoContainer.append(nameSpan, metaSpan); @@ -66,7 +67,7 @@ const updateUI = () => { return getPDFDocument(buffer).promise; }) .then((pdf) => { - metaSpan.textContent = `${formatBytes(file.size)} • ${pdf.numPages} page${pdf.numPages !== 1 ? 's' : ''}`; + metaSpan.textContent = `${formatBytes(file.size)} • ${pdf.numPages} ${pdf.numPages !== 1 ? t('common.pages') : t('common.page')}`; }) .catch((e) => { console.warn('Error loading PDF page count:', e); @@ -94,10 +95,13 @@ const resetState = () => { async function convert() { if (files.length === 0) { - showAlert('No File', 'Please upload a PDF file first.'); + showAlert( + t('tools:pdfToPng.alert.noFile'), + t('tools:pdfToPng.alert.noFileExplanation') + ); return; } - showLoader('Converting to PNG...'); + showLoader(t('tools:pdfToPng.loader.converting')); try { const pdf = await getPDFDocument(await readFileAsArrayBuffer(files[0])) .promise; @@ -124,8 +128,8 @@ async function convert() { } showAlert( - 'Success', - 'PDF converted to PNGs successfully!', + t('common.success'), + t('tools:pdfToPng.alert.conversionSuccess'), 'success', () => { resetState(); @@ -133,10 +137,7 @@ async function convert() { ); } catch (e) { console.error(e); - showAlert( - 'Error', - 'Failed to convert PDF to PNG. The file might be corrupted.' - ); + showAlert(t('common.error'), t('tools:pdfToPng.alert.conversionError')); } finally { hideLoader(); } @@ -191,7 +192,10 @@ document.addEventListener('DOMContentLoaded', () => { ); if (validFiles.length === 0) { - showAlert('Invalid File', 'Please upload a PDF file.'); + showAlert( + t('tools:pdfToPng.alert.invalidFile'), + t('tools:pdfToPng.alert.invalidFileExplanation') + ); return; } diff --git a/src/js/logic/pdf-to-tiff-page.ts b/src/js/logic/pdf-to-tiff-page.ts index 10ad314..f247a21 100644 --- a/src/js/logic/pdf-to-tiff-page.ts +++ b/src/js/logic/pdf-to-tiff-page.ts @@ -11,6 +11,7 @@ import JSZip from 'jszip'; import * as pdfjsLib from 'pdfjs-dist'; import UTIF from 'utif'; import { PDFPageProxy } from 'pdfjs-dist'; +import { t } from '../i18n/i18n'; pdfjsLib.GlobalWorkerOptions.workerSrc = new URL( 'pdfjs-dist/build/pdf.worker.min.mjs', @@ -45,7 +46,7 @@ const updateUI = () => { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(file.size)} • Loading pages...`; // Initial state + metaSpan.textContent = `${formatBytes(file.size)} • ${t('common.loadingPageCount')}`; // Initial state infoContainer.append(nameSpan, metaSpan); @@ -67,7 +68,7 @@ const updateUI = () => { return getPDFDocument(buffer).promise; }) .then((pdf) => { - metaSpan.textContent = `${formatBytes(file.size)} • ${pdf.numPages} page${pdf.numPages !== 1 ? 's' : ''}`; + metaSpan.textContent = `${formatBytes(file.size)} • ${pdf.numPages} ${pdf.numPages !== 1 ? t('common.pages') : t('common.page')}`; }) .catch((e) => { console.warn('Error loading PDF page count:', e); @@ -91,10 +92,13 @@ const resetState = () => { async function convert() { if (files.length === 0) { - showAlert('No File', 'Please upload a PDF file first.'); + showAlert( + t('tools:pdfToTiff.alert.noFile'), + t('tools:pdfToTiff.alert.noFileExplanation') + ); return; } - showLoader('Converting to TIFF...'); + showLoader(t('tools:pdfToTiff.loader.converting')); try { const pdf = await getPDFDocument(await readFileAsArrayBuffer(files[0])) .promise; @@ -121,8 +125,8 @@ async function convert() { } showAlert( - 'Success', - 'PDF converted to TIFFs successfully!', + t('common.success'), + t('tools:pdfToTiff.alert.conversionSuccess'), 'success', () => { resetState(); @@ -130,10 +134,7 @@ async function convert() { ); } catch (e) { console.error(e); - showAlert( - 'Error', - 'Failed to convert PDF to TIFF. The file might be corrupted.' - ); + showAlert(t('common.error'), t('tools:pdfToTiff.alert.conversionError')); } finally { hideLoader(); } @@ -211,7 +212,10 @@ document.addEventListener('DOMContentLoaded', () => { ); if (validFiles.length === 0) { - showAlert('Invalid File', 'Please upload a PDF file.'); + showAlert( + t('tools:pdfToTiff.alert.invalidFile'), + t('tools:pdfToTiff.alert.invalidFileExplanation') + ); return; } diff --git a/src/js/logic/pdf-to-webp-page.ts b/src/js/logic/pdf-to-webp-page.ts index c2c0fec..c991752 100644 --- a/src/js/logic/pdf-to-webp-page.ts +++ b/src/js/logic/pdf-to-webp-page.ts @@ -10,6 +10,7 @@ import { createIcons, icons } from 'lucide'; import JSZip from 'jszip'; import * as pdfjsLib from 'pdfjs-dist'; import { PDFPageProxy } from 'pdfjs-dist'; +import { t } from '../i18n/i18n'; pdfjsLib.GlobalWorkerOptions.workerSrc = new URL( 'pdfjs-dist/build/pdf.worker.min.mjs', @@ -44,7 +45,7 @@ const updateUI = () => { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(file.size)} • Loading pages...`; // Initial state + metaSpan.textContent = `${formatBytes(file.size)} • ${t('common.loadingPageCount')}`; // Initial state infoContainer.append(nameSpan, metaSpan); @@ -66,7 +67,7 @@ const updateUI = () => { return getPDFDocument(buffer).promise; }) .then((pdf) => { - metaSpan.textContent = `${formatBytes(file.size)} • ${pdf.numPages} page${pdf.numPages !== 1 ? 's' : ''}`; + metaSpan.textContent = `${formatBytes(file.size)} • ${pdf.numPages} ${pdf.numPages !== 1 ? t('common.pages') : t('common.page')}`; }) .catch((e) => { console.warn('Error loading PDF page count:', e); @@ -96,10 +97,13 @@ const resetState = () => { async function convert() { if (files.length === 0) { - showAlert('No File', 'Please upload a PDF file first.'); + showAlert( + t('tools:pdfToWebp.alert.noFile'), + t('tools:pdfToWebp.alert.noFileExplanation') + ); return; } - showLoader('Converting to WebP...'); + showLoader(t('tools:pdfToWebp.loader.converting')); try { const pdf = await getPDFDocument(await readFileAsArrayBuffer(files[0])) .promise; @@ -128,8 +132,8 @@ async function convert() { } showAlert( - 'Success', - 'PDF converted to WebPs successfully!', + t('common.success'), + t('tools:pdfToWebp.alert.conversionSuccess'), 'success', () => { resetState(); @@ -137,10 +141,7 @@ async function convert() { ); } catch (e) { console.error(e); - showAlert( - 'Error', - 'Failed to convert PDF to WebP. The file might be corrupted.' - ); + showAlert(t('common.error'), t('tools:pdfToWebp.alert.conversionError')); } finally { hideLoader(); } @@ -197,7 +198,10 @@ document.addEventListener('DOMContentLoaded', () => { ); if (validFiles.length === 0) { - showAlert('Invalid File', 'Please upload a PDF file.'); + showAlert( + t('tools:pdfToWebp.alert.invalidFile'), + t('tools:pdfToWebp.alert.invalidFileExplanation') + ); return; } diff --git a/src/js/logic/prepare-pdf-for-ai-page.ts b/src/js/logic/prepare-pdf-for-ai-page.ts index 464f522..e65dd48 100644 --- a/src/js/logic/prepare-pdf-for-ai-page.ts +++ b/src/js/logic/prepare-pdf-for-ai-page.ts @@ -1,4 +1,5 @@ import { showLoader, hideLoader, showAlert } from '../ui.js'; +import { t } from '../i18n/i18n'; import { downloadFile, readFileAsArrayBuffer, @@ -50,7 +51,7 @@ document.addEventListener('DOMContentLoaded', () => { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(file.size)} • Loading pages...`; + metaSpan.textContent = `${formatBytes(file.size)} • ${t('common.loadingPageCount')}`; infoContainer.append(nameSpan, metaSpan); diff --git a/src/js/logic/rasterize-pdf-page.ts b/src/js/logic/rasterize-pdf-page.ts index fc9960b..8949c7b 100644 --- a/src/js/logic/rasterize-pdf-page.ts +++ b/src/js/logic/rasterize-pdf-page.ts @@ -1,4 +1,5 @@ import { showLoader, hideLoader, showAlert } from '../ui.js'; +import { t } from '../i18n/i18n'; import { downloadFile, readFileAsArrayBuffer, @@ -50,7 +51,7 @@ document.addEventListener('DOMContentLoaded', () => { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(file.size)} • Loading pages...`; + metaSpan.textContent = `${formatBytes(file.size)} • ${t('common.loadingPageCount')}`; infoContainer.append(nameSpan, metaSpan); diff --git a/src/js/logic/scanner-effect-page.ts b/src/js/logic/scanner-effect-page.ts index a93bb8c..bae63b6 100644 --- a/src/js/logic/scanner-effect-page.ts +++ b/src/js/logic/scanner-effect-page.ts @@ -10,6 +10,7 @@ import { PDFDocument } from 'pdf-lib'; import { applyScannerEffect } from '../utils/image-effects.js'; import * as pdfjsLib from 'pdfjs-dist'; import type { ScanSettings } from '../types/scanner-effect-type.js'; +import { t } from '../i18n/i18n'; pdfjsLib.GlobalWorkerOptions.workerSrc = new URL( 'pdfjs-dist/build/pdf.worker.min.mjs', @@ -129,7 +130,7 @@ const updateUI = () => { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(file.size)} • Loading pages...`; + metaSpan.textContent = `${formatBytes(file.size)} • ${t('common.loadingPageCount')}`; infoContainer.append(nameSpan, metaSpan); @@ -152,7 +153,7 @@ const updateUI = () => { return getPDFDocument(buffer).promise; }) .then((pdf: pdfjsLib.PDFDocumentProxy) => { - metaSpan.textContent = `${formatBytes(file.size)} • ${pdf.numPages} page${pdf.numPages !== 1 ? 's' : ''}`; + metaSpan.textContent = `${formatBytes(file.size)} • ${pdf.numPages} ${pdf.numPages !== 1 ? t('common.pages') : t('common.page')}`; }) .catch(() => { metaSpan.textContent = formatBytes(file.size); diff --git a/src/js/logic/sign-pdf-page.ts b/src/js/logic/sign-pdf-page.ts index 8f04273..633e8fd 100644 --- a/src/js/logic/sign-pdf-page.ts +++ b/src/js/logic/sign-pdf-page.ts @@ -2,6 +2,7 @@ import { createIcons, icons } from 'lucide'; import { showAlert, showLoader, hideLoader } from '../ui.js'; import { readFileAsArrayBuffer, formatBytes, downloadFile, getPDFDocument } from '../utils/helpers.js'; import { PDFDocument } from 'pdf-lib'; +import { t } from '../i18n/i18n'; interface SignState { file: File | null; @@ -108,7 +109,7 @@ async function updateFileDisplay() { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(signState.file.size)} • Loading pages...`; + metaSpan.textContent = `${formatBytes(signState.file.size)} • ${t('common.loadingPageCount')}`; infoContainer.append(nameSpan, metaSpan); diff --git a/src/js/logic/split-pdf-page.ts b/src/js/logic/split-pdf-page.ts index 699c248..a130815 100644 --- a/src/js/logic/split-pdf-page.ts +++ b/src/js/logic/split-pdf-page.ts @@ -1,4 +1,5 @@ import { showLoader, hideLoader, showAlert } from '../ui.js'; +import { t } from '../i18n/i18n'; import { createIcons, icons } from 'lucide'; import * as pdfjsLib from 'pdfjs-dist'; import { @@ -71,7 +72,7 @@ document.addEventListener('DOMContentLoaded', () => { const metaSpan = document.createElement('div'); metaSpan.className = 'text-xs text-gray-400'; - metaSpan.textContent = `${formatBytes(file.size)} • Loading pages...`; // Placeholder + metaSpan.textContent = `${formatBytes(file.size)} • ${t('common.loadingPageCount')}`; // Placeholder infoContainer.append(nameSpan, metaSpan); diff --git a/src/pages/pdf-to-bmp.html b/src/pages/pdf-to-bmp.html index 31c8c87..75c674c 100644 --- a/src/pages/pdf-to-bmp.html +++ b/src/pages/pdf-to-bmp.html @@ -159,8 +159,12 @@
diff --git a/src/pages/pdf-to-jpg.html b/src/pages/pdf-to-jpg.html index dcee91c..64ad002 100644 --- a/src/pages/pdf-to-jpg.html +++ b/src/pages/pdf-to-jpg.html @@ -166,6 +166,7 @@
@@ -184,13 +185,20 @@ >90%
-

+

Higher quality = larger file size

- diff --git a/src/pages/pdf-to-png.html b/src/pages/pdf-to-png.html index 0853293..e5c54a5 100644 --- a/src/pages/pdf-to-png.html +++ b/src/pages/pdf-to-png.html @@ -163,6 +163,7 @@
@@ -181,13 +182,20 @@ >2.0x
-

+

Higher scale = better quality but larger file size

- diff --git a/src/pages/pdf-to-tiff.html b/src/pages/pdf-to-tiff.html index f4292dc..8980324 100644 --- a/src/pages/pdf-to-tiff.html +++ b/src/pages/pdf-to-tiff.html @@ -154,8 +154,12 @@
diff --git a/src/pages/pdf-to-webp.html b/src/pages/pdf-to-webp.html index 0501482..cb8c870 100644 --- a/src/pages/pdf-to-webp.html +++ b/src/pages/pdf-to-webp.html @@ -163,6 +163,7 @@
@@ -181,13 +182,20 @@ >85%
-

+

Higher quality = larger file size

-