mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-12-29 16:16:02 +00:00
fix: i18n tsc
This commit is contained in:
@@ -10,7 +10,7 @@ import ToolFileResult from '@components/result/ToolFileResult';
|
||||
import SimpleRadio from '@components/options/SimpleRadio';
|
||||
import { CardExampleType } from '@components/examples/ToolExamples';
|
||||
import { PDFDocument } from 'pdf-lib';
|
||||
import { CustomSnackBarContext } from '@contexts/CustomSnackBarContext';
|
||||
import { CustomSnackBarContext } from '../../../../contexts/CustomSnackBarContext';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const initialValues: InitialValuesType = {
|
||||
@@ -51,7 +51,7 @@ export default function CompressPdf({
|
||||
title,
|
||||
longDescription
|
||||
}: ToolComponentProps) {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslation('pdf');
|
||||
const [input, setInput] = useState<File | null>(null);
|
||||
const [result, setResult] = useState<File | null>(null);
|
||||
const [resultSize, setResultSize] = useState<string>('');
|
||||
@@ -80,7 +80,7 @@ export default function CompressPdf({
|
||||
} catch (error) {
|
||||
console.error('Error getting PDF info:', error);
|
||||
setFileInfo(null);
|
||||
showSnackBar(t('pdf:compressPdf.errorReadingPdf'), 'error');
|
||||
showSnackBar(t('compressPdf.errorReadingPdf'), 'error');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -112,7 +112,7 @@ export default function CompressPdf({
|
||||
} catch (error) {
|
||||
console.error('Error compressing PDF:', error);
|
||||
showSnackBar(
|
||||
t('pdf:compressPdf.errorCompressingPdf', {
|
||||
t('compressPdf.errorCompressingPdf', {
|
||||
error: error instanceof Error ? error.message : String(error)
|
||||
}),
|
||||
'error'
|
||||
@@ -130,18 +130,18 @@ export default function CompressPdf({
|
||||
}[] = [
|
||||
{
|
||||
value: 'low',
|
||||
label: t('pdf:compressPdf.lowCompression'),
|
||||
description: t('pdf:compressPdf.lowCompressionDescription')
|
||||
label: t('compressPdf.lowCompression'),
|
||||
description: t('compressPdf.lowCompressionDescription')
|
||||
},
|
||||
{
|
||||
value: 'medium',
|
||||
label: t('pdf:compressPdf.mediumCompression'),
|
||||
description: t('pdf:compressPdf.mediumCompressionDescription')
|
||||
label: t('compressPdf.mediumCompression'),
|
||||
description: t('compressPdf.mediumCompressionDescription')
|
||||
},
|
||||
{
|
||||
value: 'high',
|
||||
label: t('pdf:compressPdf.highCompression'),
|
||||
description: t('pdf:compressPdf.highCompressionDescription')
|
||||
label: t('compressPdf.highCompression'),
|
||||
description: t('compressPdf.highCompressionDescription')
|
||||
}
|
||||
];
|
||||
|
||||
@@ -157,26 +157,26 @@ export default function CompressPdf({
|
||||
value={input}
|
||||
onChange={setInput}
|
||||
accept={['application/pdf']}
|
||||
title={t('pdf:compressPdf.inputTitle')}
|
||||
title={t('compressPdf.inputTitle')}
|
||||
/>
|
||||
}
|
||||
resultComponent={
|
||||
<ToolFileResult
|
||||
title={t('pdf:compressPdf.resultTitle')}
|
||||
title={t('compressPdf.resultTitle')}
|
||||
value={result}
|
||||
extension={'pdf'}
|
||||
loading={isProcessing}
|
||||
loadingText={t('pdf:compressPdf.compressingPdf')}
|
||||
loadingText={t('compressPdf.compressingPdf')}
|
||||
/>
|
||||
}
|
||||
getGroups={({ values, updateField }) => [
|
||||
{
|
||||
title: t('pdf:compressPdf.compressionSettings'),
|
||||
title: t('compressPdf.compressionSettings'),
|
||||
component: (
|
||||
<Box>
|
||||
<Box>
|
||||
<Typography variant="subtitle2" sx={{ mb: 1 }}>
|
||||
{t('pdf:compressPdf.compressionLevel')}
|
||||
{t('compressPdf.compressionLevel')}
|
||||
</Typography>
|
||||
|
||||
{compressionOptions.map((option) => (
|
||||
@@ -201,16 +201,15 @@ export default function CompressPdf({
|
||||
}}
|
||||
>
|
||||
<Typography variant="body2">
|
||||
{t('pdf:compressPdf.fileSize')}:{' '}
|
||||
{t('compressPdf.fileSize')}:{' '}
|
||||
<strong>{fileInfo.size}</strong>
|
||||
</Typography>
|
||||
<Typography variant="body2">
|
||||
{t('pdf:compressPdf.pages')}:{' '}
|
||||
<strong>{fileInfo.pages}</strong>
|
||||
{t('compressPdf.pages')}: <strong>{fileInfo.pages}</strong>
|
||||
</Typography>
|
||||
{resultSize && (
|
||||
<Typography variant="body2">
|
||||
{t('pdf:compressPdf.compressedFileSize')}:{' '}
|
||||
{t('compressPdf.compressedFileSize')}:{' '}
|
||||
<strong>{resultSize}</strong>
|
||||
</Typography>
|
||||
)}
|
||||
|
||||
@@ -15,20 +15,6 @@
|
||||
"description": "This tool allows you to combine multiple PDF files into a single document. You can choose how to sort the PDFs and the tool will merge them in the specified order."
|
||||
}
|
||||
},
|
||||
"compressPdf": {
|
||||
"title": "Compress PDF",
|
||||
"description": "Reduce PDF file size while maintaining quality.",
|
||||
"inputTitle": "Input PDF",
|
||||
"resultTitle": "Compressed PDF",
|
||||
"compressingPdf": "Compressing PDF",
|
||||
"compressionOptions": "Compression Options",
|
||||
"qualityDescription": "Compression quality (1-100)",
|
||||
"qualityPlaceholder": "Quality",
|
||||
"toolInfo": {
|
||||
"title": "Compress PDF",
|
||||
"description": "This tool allows you to compress PDF files to reduce their size while maintaining acceptable quality. You can adjust the compression level to balance between file size and quality."
|
||||
}
|
||||
},
|
||||
"splitPdf": {
|
||||
"title": "Split PDF",
|
||||
"description": "Extract specific pages from a PDF document.",
|
||||
@@ -68,5 +54,29 @@
|
||||
"title": "How to Use the Rotate PDF Tool",
|
||||
"description": "This tool allows you to rotate pages in a PDF document. You can rotate all pages or specify individual pages to rotate. Choose a rotation angle: 90° Clockwise, 180° (Upside down), or 270° (90° Counter-clockwise). To rotate specific pages, uncheck \"Apply to all pages\" and enter page numbers or ranges separated by commas (e.g., 1,3,5-7)."
|
||||
}
|
||||
},
|
||||
"compressPdf": {
|
||||
"inputTitle": "Input PDF",
|
||||
"resultTitle": "Compressed PDF",
|
||||
"compressingPdf": "Compressing PDF...",
|
||||
|
||||
"compressionSettings": "Compression Settings",
|
||||
"compressionLevel": "Compression Level",
|
||||
|
||||
"lowCompression": "Low Compression",
|
||||
"lowCompressionDescription": "Slightly reduce file size with minimal quality loss",
|
||||
|
||||
"mediumCompression": "Medium Compression",
|
||||
"mediumCompressionDescription": "Balance between file size and quality",
|
||||
|
||||
"highCompression": "High Compression",
|
||||
"highCompressionDescription": "Maximum file size reduction with some quality loss",
|
||||
|
||||
"fileSize": "Original File Size",
|
||||
"compressedFileSize": "Compressed File Size",
|
||||
"pages": "Number of Pages",
|
||||
|
||||
"errorReadingPdf": "Failed to read PDF file. Please make sure it is a valid PDF.",
|
||||
"errorCompressingPdf": "Failed to compress PDF: {{error}}"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import ToolMultiPdfInput, {
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export default function MergePdf({ title }: ToolComponentProps) {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslation('pdf');
|
||||
const [input, setInput] = useState<MultiPdfInput[]>([]);
|
||||
const [result, setResult] = useState<File | null>(null);
|
||||
const [isProcessing, setIsProcessing] = useState<boolean>(false);
|
||||
@@ -44,23 +44,23 @@ export default function MergePdf({ title }: ToolComponentProps) {
|
||||
setInput(pdfInputs);
|
||||
}}
|
||||
accept={['application/pdf']}
|
||||
title={t('pdf:merge.inputTitle')}
|
||||
title={t('merge.inputTitle')}
|
||||
type="pdf"
|
||||
/>
|
||||
}
|
||||
getGroups={null}
|
||||
resultComponent={
|
||||
<ToolFileResult
|
||||
title={t('pdf:merge.resultTitle')}
|
||||
title={t('merge.resultTitle')}
|
||||
value={result}
|
||||
extension={'pdf'}
|
||||
loading={isProcessing}
|
||||
loadingText={t('pdf:merge.loadingText')}
|
||||
loadingText={t('merge.loadingText')}
|
||||
/>
|
||||
}
|
||||
toolInfo={{
|
||||
title: t('pdf:merge.toolInfo.title'),
|
||||
description: t('pdf:merge.toolInfo.description')
|
||||
title: t('merge.toolInfo.title'),
|
||||
description: t('merge.toolInfo.description')
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -58,7 +58,7 @@ export default function RotatePdf({
|
||||
title,
|
||||
longDescription
|
||||
}: ToolComponentProps) {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslation('pdf');
|
||||
const [input, setInput] = useState<File | null>(null);
|
||||
const [result, setResult] = useState<File | null>(null);
|
||||
const [isProcessing, setIsProcessing] = useState<boolean>(false);
|
||||
@@ -92,7 +92,7 @@ export default function RotatePdf({
|
||||
if (applyToAllPages) {
|
||||
setPageRangePreview(
|
||||
totalPages > 0
|
||||
? t('pdf:rotatePdf.allPagesWillBeRotated', { count: totalPages })
|
||||
? t('rotatePdf.allPagesWillBeRotated', { count: totalPages })
|
||||
: ''
|
||||
);
|
||||
return;
|
||||
@@ -105,7 +105,7 @@ export default function RotatePdf({
|
||||
|
||||
try {
|
||||
const count = parsePageRanges(pageRanges, totalPages).length;
|
||||
setPageRangePreview(t('pdf:rotatePdf.pagesWillBeRotated', { count }));
|
||||
setPageRangePreview(t('rotatePdf.pagesWillBeRotated', { count }));
|
||||
} catch (error) {
|
||||
setPageRangePreview('');
|
||||
}
|
||||
@@ -125,9 +125,9 @@ export default function RotatePdf({
|
||||
}
|
||||
};
|
||||
const angleOptions: { value: RotationAngle; label: string }[] = [
|
||||
{ value: 90, label: t('pdf:rotatePdf.angleOptions.clockwise90') },
|
||||
{ value: 180, label: t('pdf:rotatePdf.angleOptions.upsideDown180') },
|
||||
{ value: 270, label: t('pdf:rotatePdf.angleOptions.counterClockwise270') }
|
||||
{ value: 90, label: t('rotatePdf.angleOptions.clockwise90') },
|
||||
{ value: 180, label: t('rotatePdf.angleOptions.upsideDown180') },
|
||||
{ value: 270, label: t('rotatePdf.angleOptions.counterClockwise270') }
|
||||
];
|
||||
return (
|
||||
<ToolContent
|
||||
@@ -142,25 +142,25 @@ export default function RotatePdf({
|
||||
value={input}
|
||||
onChange={setInput}
|
||||
accept={['application/pdf']}
|
||||
title={t('pdf:rotatePdf.inputTitle')}
|
||||
title={t('rotatePdf.inputTitle')}
|
||||
/>
|
||||
}
|
||||
resultComponent={
|
||||
<ToolFileResult
|
||||
title={t('pdf:rotatePdf.resultTitle')}
|
||||
title={t('rotatePdf.resultTitle')}
|
||||
value={result}
|
||||
extension={'pdf'}
|
||||
loading={isProcessing}
|
||||
loadingText={t('pdf:rotatePdf.rotatingPages')}
|
||||
loadingText={t('rotatePdf.rotatingPages')}
|
||||
/>
|
||||
}
|
||||
getGroups={({ values, updateField }) => [
|
||||
{
|
||||
title: t('pdf:rotatePdf.rotationSettings'),
|
||||
title: t('rotatePdf.rotationSettings'),
|
||||
component: (
|
||||
<Box>
|
||||
<Typography variant="subtitle2" sx={{ mb: 1 }}>
|
||||
{t('pdf:rotatePdf.rotationAngle')}
|
||||
{t('rotatePdf.rotationAngle')}
|
||||
</Typography>
|
||||
{angleOptions.map((angleOption) => (
|
||||
<SimpleRadio
|
||||
@@ -183,7 +183,7 @@ export default function RotatePdf({
|
||||
}}
|
||||
/>
|
||||
}
|
||||
label={t('pdf:rotatePdf.applyToAllPages')}
|
||||
label={t('rotatePdf.applyToAllPages')}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
@@ -191,7 +191,7 @@ export default function RotatePdf({
|
||||
<Box sx={{ mt: 2 }}>
|
||||
{totalPages > 0 && (
|
||||
<Typography variant="body2" sx={{ mb: 1 }}>
|
||||
{t('pdf:rotatePdf.pdfPageCount', { count: totalPages })}
|
||||
{t('rotatePdf.pdfPageCount', { count: totalPages })}
|
||||
</Typography>
|
||||
)}
|
||||
<TextFieldWithDesc
|
||||
@@ -199,8 +199,8 @@ export default function RotatePdf({
|
||||
onOwnChange={(val) => {
|
||||
updateField('pageRanges', val);
|
||||
}}
|
||||
description={t('pdf:rotatePdf.pageRangesDescription')}
|
||||
placeholder={t('pdf:rotatePdf.pageRangesPlaceholder')}
|
||||
description={t('rotatePdf.pageRangesDescription')}
|
||||
placeholder={t('rotatePdf.pageRangesPlaceholder')}
|
||||
/>
|
||||
{pageRangePreview && (
|
||||
<Typography
|
||||
@@ -218,8 +218,8 @@ export default function RotatePdf({
|
||||
]}
|
||||
onValuesChange={onValuesChange}
|
||||
toolInfo={{
|
||||
title: t('pdf:rotatePdf.toolInfo.title'),
|
||||
description: t('pdf:rotatePdf.toolInfo.description')
|
||||
title: t('rotatePdf.toolInfo.title'),
|
||||
description: t('rotatePdf.toolInfo.description')
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -49,7 +49,7 @@ const exampleCards: CardExampleType<InitialValuesType>[] = [
|
||||
];
|
||||
|
||||
export default function SplitPdf({ title }: ToolComponentProps) {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslation('pdf');
|
||||
const [input, setInput] = useState<File | null>(null);
|
||||
const [result, setResult] = useState<File | null>(null);
|
||||
const [isProcessing, setIsProcessing] = useState<boolean>(false);
|
||||
@@ -85,7 +85,7 @@ export default function SplitPdf({ title }: ToolComponentProps) {
|
||||
}
|
||||
try {
|
||||
const count = parsePageRanges(pageRanges, totalPages).length;
|
||||
setPageRangePreview(t('pdf:splitPdf.pageExtractionPreview', { count }));
|
||||
setPageRangePreview(t('splitPdf.pageExtractionPreview', { count }));
|
||||
} catch (error) {
|
||||
setPageRangePreview('');
|
||||
}
|
||||
@@ -118,26 +118,26 @@ export default function SplitPdf({ title }: ToolComponentProps) {
|
||||
value={input}
|
||||
onChange={setInput}
|
||||
accept={['application/pdf']}
|
||||
title={t('pdf:splitPdf.inputTitle')}
|
||||
title={t('splitPdf.inputTitle')}
|
||||
/>
|
||||
}
|
||||
resultComponent={
|
||||
<ToolFileResult
|
||||
title={t('pdf:splitPdf.resultTitle')}
|
||||
title={t('splitPdf.resultTitle')}
|
||||
value={result}
|
||||
extension={'pdf'}
|
||||
loading={isProcessing}
|
||||
loadingText={t('pdf:splitPdf.extractingPages')}
|
||||
loadingText={t('splitPdf.extractingPages')}
|
||||
/>
|
||||
}
|
||||
getGroups={({ values, updateField }) => [
|
||||
{
|
||||
title: t('pdf:splitPdf.pageSelection'),
|
||||
title: t('splitPdf.pageSelection'),
|
||||
component: (
|
||||
<Box>
|
||||
{totalPages > 0 && (
|
||||
<Typography variant="body2" sx={{ mb: 1 }}>
|
||||
{t('pdf:splitPdf.pdfPageCount', { count: totalPages })}
|
||||
{t('splitPdf.pdfPageCount', { count: totalPages })}
|
||||
</Typography>
|
||||
)}
|
||||
<TextFieldWithDesc
|
||||
@@ -145,8 +145,8 @@ export default function SplitPdf({ title }: ToolComponentProps) {
|
||||
onOwnChange={(val) => {
|
||||
updateField('pageRanges', val);
|
||||
}}
|
||||
description={t('pdf:splitPdf.pageRangesDescription')}
|
||||
placeholder={t('pdf:splitPdf.pageRangesPlaceholder')}
|
||||
description={t('splitPdf.pageRangesDescription')}
|
||||
placeholder={t('splitPdf.pageRangesPlaceholder')}
|
||||
/>
|
||||
{pageRangePreview && (
|
||||
<Typography
|
||||
@@ -162,8 +162,8 @@ export default function SplitPdf({ title }: ToolComponentProps) {
|
||||
]}
|
||||
onValuesChange={onValuesChange}
|
||||
toolInfo={{
|
||||
title: t('pdf:splitPdf.toolInfo.title'),
|
||||
description: t('pdf:splitPdf.toolInfo.description')
|
||||
title: t('splitPdf.toolInfo.title'),
|
||||
description: t('splitPdf.toolInfo.description')
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user