Add localization to fileDisplayArea

This commit is contained in:
Sebastian Espei
2026-03-10 18:24:31 +01:00
parent b479abf6cf
commit 667385ee1c
8 changed files with 16 additions and 8 deletions

View File

@@ -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/index.js';
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.min.mjs',
@@ -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);

View File

@@ -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/index.js';
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.min.mjs',
@@ -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);

View File

@@ -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/index.js';
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.min.mjs',
@@ -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);

View File

@@ -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/index.js';
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.min.mjs',
@@ -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);

View File

@@ -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/index.js';
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.min.mjs',
@@ -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);

View File

@@ -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/index.js';
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.min.mjs',
@@ -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);

View File

@@ -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/index.js';
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.min.mjs',
@@ -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);

View File

@@ -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/index.js';
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.min.mjs',
@@ -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);