mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-07-29 00:25:28 +00:00
Translations for file management
This commit is contained in:
parent
215bb86a8e
commit
cbc5616a39
@ -1622,5 +1622,37 @@
|
|||||||
"toolPicker": {
|
"toolPicker": {
|
||||||
"searchPlaceholder": "Search tools...",
|
"searchPlaceholder": "Search tools...",
|
||||||
"noToolsFound": "No tools found"
|
"noToolsFound": "No tools found"
|
||||||
|
},
|
||||||
|
"fileUpload": {
|
||||||
|
"selectFile": "Select a file",
|
||||||
|
"selectFiles": "Select files",
|
||||||
|
"selectPdfToView": "Select a PDF to view",
|
||||||
|
"selectPdfToEdit": "Select a PDF to edit",
|
||||||
|
"chooseFromStorage": "Choose a file from storage or upload a new PDF",
|
||||||
|
"chooseFromStorageMultiple": "Choose files from storage or upload new PDFs",
|
||||||
|
"loadFromStorage": "Load from Storage",
|
||||||
|
"filesAvailable": "files available",
|
||||||
|
"loading": "Loading...",
|
||||||
|
"or": "or",
|
||||||
|
"dropFileHere": "Drop file here or click to upload",
|
||||||
|
"dropFilesHere": "Drop files here or click to upload",
|
||||||
|
"pdfFilesOnly": "PDF files only",
|
||||||
|
"supportedFileTypes": "Supported file types",
|
||||||
|
"uploadFile": "Upload File",
|
||||||
|
"uploadFiles": "Upload Files",
|
||||||
|
"noFilesInStorage": "No files available in storage. Upload some files first.",
|
||||||
|
"selectFromStorage": "Select from Storage",
|
||||||
|
"backToTools": "Back to Tools"
|
||||||
|
},
|
||||||
|
"fileManager": {
|
||||||
|
"title": "Upload PDF Files",
|
||||||
|
"subtitle": "Add files to your storage for easy access across tools",
|
||||||
|
"filesSelected": "files selected",
|
||||||
|
"clearSelection": "Clear Selection",
|
||||||
|
"openInFileEditor": "Open in File Editor",
|
||||||
|
"uploadError": "Failed to upload some files.",
|
||||||
|
"failedToOpen": "Failed to open file. It may have been removed from storage.",
|
||||||
|
"failedToLoad": "Failed to load file to active set.",
|
||||||
|
"storageCleared": "Browser cleared storage. Files have been removed. Please re-upload."
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -133,7 +133,7 @@ const FileManager = ({
|
|||||||
const isPurged = await checkForPurge(files);
|
const isPurged = await checkForPurge(files);
|
||||||
if (isPurged) {
|
if (isPurged) {
|
||||||
console.warn('IndexedDB purge detected - forcing UI reload');
|
console.warn('IndexedDB purge detected - forcing UI reload');
|
||||||
setNotification('Browser cleared storage. Files have been removed. Please re-upload.');
|
setNotification(t("fileManager.storageCleared", "Browser cleared storage. Files have been removed. Please re-upload."));
|
||||||
const reloadedFiles = await forceReloadFiles();
|
const reloadedFiles = await forceReloadFiles();
|
||||||
setFiles(reloadedFiles);
|
setFiles(reloadedFiles);
|
||||||
setFilesLoaded(true);
|
setFilesLoaded(true);
|
||||||
@ -220,7 +220,7 @@ const FileManager = ({
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to load file to active set:', error);
|
console.error('Failed to load file to active set:', error);
|
||||||
setNotification('Failed to open file. It may have been removed from storage.');
|
setNotification(t("fileManager.failedToOpen", "Failed to open file. It may have been removed from storage."));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ const FileManager = ({
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to load file to active set:', error);
|
console.error('Failed to load file to active set:', error);
|
||||||
setNotification('Failed to open file. It may have been removed from storage.');
|
setNotification(t("fileManager.failedToOpen", "Failed to open file. It may have been removed from storage."));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -309,7 +309,7 @@ const FileManager = ({
|
|||||||
<Box mb="md" p="md" style={{ backgroundColor: 'var(--mantine-color-blue-0)', borderRadius: 8 }}>
|
<Box mb="md" p="md" style={{ backgroundColor: 'var(--mantine-color-blue-0)', borderRadius: 8 }}>
|
||||||
<Group justify="space-between">
|
<Group justify="space-between">
|
||||||
<Text size="sm">
|
<Text size="sm">
|
||||||
{selectedFiles.length} file{selectedFiles.length > 1 ? 's' : ''} selected
|
{selectedFiles.length} {t("fileManager.filesSelected", "files selected")}
|
||||||
</Text>
|
</Text>
|
||||||
<Group>
|
<Group>
|
||||||
<Button
|
<Button
|
||||||
@ -317,7 +317,7 @@ const FileManager = ({
|
|||||||
variant="light"
|
variant="light"
|
||||||
onClick={() => setSelectedFiles([])}
|
onClick={() => setSelectedFiles([])}
|
||||||
>
|
>
|
||||||
Clear Selection
|
{t("fileManager.clearSelection", "Clear Selection")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
size="xs"
|
size="xs"
|
||||||
@ -325,7 +325,7 @@ const FileManager = ({
|
|||||||
onClick={handleOpenSelectedInEditor}
|
onClick={handleOpenSelectedInEditor}
|
||||||
disabled={selectedFiles.length === 0}
|
disabled={selectedFiles.length === 0}
|
||||||
>
|
>
|
||||||
Open in File Editor
|
{t("fileManager.openInFileEditor", "Open in File Editor")}
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
@ -335,8 +335,8 @@ const FileManager = ({
|
|||||||
{/* Files Display */}
|
{/* Files Display */}
|
||||||
{files.length === 0 ? (
|
{files.length === 0 ? (
|
||||||
<FileUploadSelector
|
<FileUploadSelector
|
||||||
title="Upload PDF Files"
|
title={t("fileManager.title", "Upload PDF Files")}
|
||||||
subtitle="Add files to your storage for easy access across tools"
|
subtitle={t("fileManager.subtitle", "Add files to your storage for easy access across tools")}
|
||||||
sharedFiles={[]} // FileManager is the source, so no shared files
|
sharedFiles={[]} // FileManager is the source, so no shared files
|
||||||
onFilesSelect={(uploadedFiles) => {
|
onFilesSelect={(uploadedFiles) => {
|
||||||
// Handle multiple files - add to storage AND active set
|
// Handle multiple files - add to storage AND active set
|
||||||
|
@ -123,28 +123,28 @@ const FilePickerModal = ({
|
|||||||
<Modal
|
<Modal
|
||||||
opened={opened}
|
opened={opened}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
title="Select Files from Storage"
|
title={t("fileUpload.selectFromStorage", "Select Files from Storage")}
|
||||||
size="lg"
|
size="lg"
|
||||||
scrollAreaComponent={ScrollArea.Autosize}
|
scrollAreaComponent={ScrollArea.Autosize}
|
||||||
>
|
>
|
||||||
<Stack gap="md">
|
<Stack gap="md">
|
||||||
{sharedFiles.length === 0 ? (
|
{sharedFiles.length === 0 ? (
|
||||||
<Text c="dimmed" ta="center" py="xl">
|
<Text c="dimmed" ta="center" py="xl">
|
||||||
No files available in storage. Upload some files first.
|
{t("fileUpload.noFilesInStorage", "No files available in storage. Upload some files first.")}
|
||||||
</Text>
|
</Text>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{/* Selection controls */}
|
{/* Selection controls */}
|
||||||
<Group justify="space-between">
|
<Group justify="space-between">
|
||||||
<Text size="sm" c="dimmed">
|
<Text size="sm" c="dimmed">
|
||||||
{sharedFiles.length} files available
|
{sharedFiles.length} {t("fileUpload.filesAvailable", "files available")}
|
||||||
</Text>
|
</Text>
|
||||||
<Group gap="xs">
|
<Group gap="xs">
|
||||||
<Button size="xs" variant="light" onClick={selectAll}>
|
<Button size="xs" variant="light" onClick={selectAll}>
|
||||||
Select All
|
{t("pageEdit.selectAll", "Select All")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button size="xs" variant="light" onClick={selectNone}>
|
<Button size="xs" variant="light" onClick={selectNone}>
|
||||||
Select None
|
{t("pageEdit.deselectAll", "Select None")}
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
@ -234,7 +234,7 @@ const FilePickerModal = ({
|
|||||||
{/* Selection summary */}
|
{/* Selection summary */}
|
||||||
{selectedFileIds.length > 0 && (
|
{selectedFileIds.length > 0 && (
|
||||||
<Text size="sm" c="blue" ta="center">
|
<Text size="sm" c="blue" ta="center">
|
||||||
{selectedFileIds.length} file{selectedFileIds.length > 1 ? 's' : ''} selected
|
{selectedFileIds.length} {t("fileManager.filesSelected", "files selected")}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
@ -243,13 +243,16 @@ const FilePickerModal = ({
|
|||||||
{/* Action buttons */}
|
{/* Action buttons */}
|
||||||
<Group justify="flex-end" mt="md">
|
<Group justify="flex-end" mt="md">
|
||||||
<Button variant="light" onClick={onClose}>
|
<Button variant="light" onClick={onClose}>
|
||||||
Cancel
|
{t("close", "Cancel")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={handleConfirm}
|
onClick={handleConfirm}
|
||||||
disabled={selectedFileIds.length === 0}
|
disabled={selectedFileIds.length === 0}
|
||||||
>
|
>
|
||||||
Load {selectedFileIds.length > 0 ? `${selectedFileIds.length} ` : ''}Files
|
{selectedFileIds.length > 0
|
||||||
|
? `${t("fileUpload.loadFromStorage", "Load")} ${selectedFileIds.length} ${t("fileUpload.uploadFiles", "Files")}`
|
||||||
|
: t("fileUpload.loadFromStorage", "Load Files")
|
||||||
|
}
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
@ -24,8 +24,8 @@ interface FileUploadSelectorProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const FileUploadSelector = ({
|
const FileUploadSelector = ({
|
||||||
title = "Select a file",
|
title,
|
||||||
subtitle = "Choose from storage or upload a new file",
|
subtitle,
|
||||||
showDropzone = true,
|
showDropzone = true,
|
||||||
sharedFiles = [],
|
sharedFiles = [],
|
||||||
onFileSelect,
|
onFileSelect,
|
||||||
@ -58,6 +58,12 @@ const FileUploadSelector = ({
|
|||||||
}
|
}
|
||||||
}, [allowMultiple, onFileSelect, onFilesSelect]);
|
}, [allowMultiple, onFileSelect, onFilesSelect]);
|
||||||
|
|
||||||
|
// Get default title and subtitle from translations if not provided
|
||||||
|
const displayTitle = title || t(allowMultiple ? "fileUpload.selectFiles" : "fileUpload.selectFile",
|
||||||
|
allowMultiple ? "Select files" : "Select a file");
|
||||||
|
const displaySubtitle = subtitle || t(allowMultiple ? "fileUpload.chooseFromStorageMultiple" : "fileUpload.chooseFromStorage",
|
||||||
|
allowMultiple ? "Choose files from storage or upload new PDFs" : "Choose a file from storage or upload a new PDF");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack align="center" gap="xl">
|
<Stack align="center" gap="xl">
|
||||||
@ -65,10 +71,10 @@ const FileUploadSelector = ({
|
|||||||
<Stack align="center" gap="md">
|
<Stack align="center" gap="md">
|
||||||
<UploadFileIcon style={{ fontSize: 64 }} />
|
<UploadFileIcon style={{ fontSize: 64 }} />
|
||||||
<Text size="xl" fw={500}>
|
<Text size="xl" fw={500}>
|
||||||
{title}
|
{displayTitle}
|
||||||
</Text>
|
</Text>
|
||||||
<Text size="md" c="dimmed">
|
<Text size="md" c="dimmed">
|
||||||
{subtitle}
|
{displaySubtitle}
|
||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
@ -81,11 +87,14 @@ const FileUploadSelector = ({
|
|||||||
disabled={disabled || sharedFiles.length === 0}
|
disabled={disabled || sharedFiles.length === 0}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
>
|
>
|
||||||
{loading ? "Loading..." : `Load from Storage (${sharedFiles.length} files available)`}
|
{loading
|
||||||
|
? t("fileUpload.loading", "Loading...")
|
||||||
|
: `${t("fileUpload.loadFromStorage", "Load from Storage")} (${sharedFiles.length} ${t("fileUpload.filesAvailable", "files available")})`
|
||||||
|
}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Text size="md" c="dimmed">
|
<Text size="md" c="dimmed">
|
||||||
or
|
{t("fileUpload.or", "or")}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
{showDropzone ? (
|
{showDropzone ? (
|
||||||
@ -99,10 +108,14 @@ const FileUploadSelector = ({
|
|||||||
<Center>
|
<Center>
|
||||||
<Stack align="center" gap="sm">
|
<Stack align="center" gap="sm">
|
||||||
<Text size="md" fw={500}>
|
<Text size="md" fw={500}>
|
||||||
{allowMultiple ? 'Drop files here or click to upload' : 'Drop file here or click to upload'}
|
{t(allowMultiple ? "fileUpload.dropFilesHere" : "fileUpload.dropFileHere",
|
||||||
|
allowMultiple ? "Drop files here or click to upload" : "Drop file here or click to upload")}
|
||||||
</Text>
|
</Text>
|
||||||
<Text size="sm" c="dimmed">
|
<Text size="sm" c="dimmed">
|
||||||
{accept.includes('application/pdf') ? 'PDF files only' : 'Supported file types'}
|
{accept.includes('application/pdf')
|
||||||
|
? t("fileUpload.pdfFilesOnly", "PDF files only")
|
||||||
|
: t("fileUpload.supportedFileTypes", "Supported file types")
|
||||||
|
}
|
||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Center>
|
</Center>
|
||||||
@ -121,7 +134,8 @@ const FileUploadSelector = ({
|
|||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
>
|
>
|
||||||
Upload {allowMultiple ? 'Files' : 'File'}
|
{t(allowMultiple ? "fileUpload.uploadFiles" : "fileUpload.uploadFile",
|
||||||
|
allowMultiple ? "Upload Files" : "Upload File")}
|
||||||
</Button>
|
</Button>
|
||||||
</Dropzone>
|
</Dropzone>
|
||||||
)}
|
)}
|
||||||
|
@ -241,7 +241,7 @@ export default function HomePage() {
|
|||||||
onClick={() => setLeftPanelView('toolPicker')}
|
onClick={() => setLeftPanelView('toolPicker')}
|
||||||
className="text-sm"
|
className="text-sm"
|
||||||
>
|
>
|
||||||
← Back to Tools
|
← {t("fileUpload.backToTools", "Back to Tools")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -293,8 +293,11 @@ export default function HomePage() {
|
|||||||
) : (currentView != "fileManager") && !activeFiles[0] ? (
|
) : (currentView != "fileManager") && !activeFiles[0] ? (
|
||||||
<Container size="lg" p="xl" h="100%" style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
<Container size="lg" p="xl" h="100%" style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||||||
<FileUploadSelector
|
<FileUploadSelector
|
||||||
title={currentView === "viewer" ? "Select a PDF to view" : "Select a PDF to edit"}
|
title={currentView === "viewer"
|
||||||
subtitle="Choose a file from storage or upload a new PDF"
|
? t("fileUpload.selectPdfToView", "Select a PDF to view")
|
||||||
|
: t("fileUpload.selectPdfToEdit", "Select a PDF to edit")
|
||||||
|
}
|
||||||
|
subtitle={t("fileUpload.chooseFromStorage", "Choose a file from storage or upload a new PDF")}
|
||||||
sharedFiles={storedFiles}
|
sharedFiles={storedFiles}
|
||||||
onFileSelect={(file) => {
|
onFileSelect={(file) => {
|
||||||
addToActiveFiles(file);
|
addToActiveFiles(file);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user