Merge pull request #565 from Skillkiller/translate-pdf-to-image
Implement missing i18n translations for PDF-to-Image modules
This commit is contained in:
@@ -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": {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<void> {
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -159,8 +159,12 @@
|
||||
<div id="file-display-area" class="mt-4 space-y-2"></div>
|
||||
|
||||
<div id="options-panel" class="hidden mt-6">
|
||||
<button id="process-btn" class="btn-gradient w-full">
|
||||
Download All
|
||||
<button
|
||||
id="process-btn"
|
||||
class="btn-gradient w-full"
|
||||
data-i18n="common.convert"
|
||||
>
|
||||
Convert
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -166,6 +166,7 @@
|
||||
<label
|
||||
for="jpg-quality"
|
||||
class="block mb-2 text-sm font-medium text-gray-300"
|
||||
data-i18n="tools:pdfToJpg.imageQuality"
|
||||
>Image Quality</label
|
||||
>
|
||||
<div class="flex items-center gap-4">
|
||||
@@ -184,13 +185,20 @@
|
||||
>90%</span
|
||||
>
|
||||
</div>
|
||||
<p class="mt-1 text-xs text-gray-400">
|
||||
<p
|
||||
class="mt-1 text-xs text-gray-400"
|
||||
data-i18n="tools:pdfToJpg.imageQualityExplanation"
|
||||
>
|
||||
Higher quality = larger file size
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<button id="process-btn" class="btn-gradient w-full">
|
||||
Download All
|
||||
<button
|
||||
id="process-btn"
|
||||
class="btn-gradient w-full"
|
||||
data-i18n="common.convert"
|
||||
>
|
||||
Convert
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -163,6 +163,7 @@
|
||||
<label
|
||||
for="png-scale"
|
||||
class="block mb-2 text-sm font-medium text-gray-300"
|
||||
data-i18n="tools:pdfToPng.imageScale"
|
||||
>Image Scale</label
|
||||
>
|
||||
<div class="flex items-center gap-4">
|
||||
@@ -181,13 +182,20 @@
|
||||
>2.0x</span
|
||||
>
|
||||
</div>
|
||||
<p class="mt-1 text-xs text-gray-400">
|
||||
<p
|
||||
class="mt-1 text-xs text-gray-400"
|
||||
data-i18n="tools:pdfToPng.imageScaleExplanation"
|
||||
>
|
||||
Higher scale = better quality but larger file size
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<button id="process-btn" class="btn-gradient w-full">
|
||||
Download All
|
||||
<button
|
||||
id="process-btn"
|
||||
class="btn-gradient w-full"
|
||||
data-i18n="common.convert"
|
||||
>
|
||||
Convert
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -154,8 +154,12 @@
|
||||
</div>
|
||||
<div id="file-display-area" class="mt-4 space-y-2"></div>
|
||||
<div id="options-panel" class="hidden mt-6">
|
||||
<button id="process-btn" class="btn-gradient w-full">
|
||||
Download All
|
||||
<button
|
||||
id="process-btn"
|
||||
class="btn-gradient w-full"
|
||||
data-i18n="common.convert"
|
||||
>
|
||||
Convert
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -163,6 +163,7 @@
|
||||
<label
|
||||
for="webp-quality"
|
||||
class="block mb-2 text-sm font-medium text-gray-300"
|
||||
data-i18n="tools:pdfToWebp.imageQuality"
|
||||
>Image Quality</label
|
||||
>
|
||||
<div class="flex items-center gap-4">
|
||||
@@ -181,13 +182,20 @@
|
||||
>85%</span
|
||||
>
|
||||
</div>
|
||||
<p class="mt-1 text-xs text-gray-400">
|
||||
<p
|
||||
class="mt-1 text-xs text-gray-400"
|
||||
data-i18n="tools:pdfToWebp.imageQualityExplanation"
|
||||
>
|
||||
Higher quality = larger file size
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<button id="process-btn" class="btn-gradient w-full">
|
||||
Download All
|
||||
<button
|
||||
id="process-btn"
|
||||
class="btn-gradient w-full"
|
||||
data-i18n="common.convert"
|
||||
>
|
||||
Convert
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user