mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-07-27 07:35:22 +00:00
Translations for file management
This commit is contained in:
parent
215bb86a8e
commit
cbc5616a39
@ -1622,5 +1622,37 @@
|
||||
"toolPicker": {
|
||||
"searchPlaceholder": "Search tools...",
|
||||
"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);
|
||||
if (isPurged) {
|
||||
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();
|
||||
setFiles(reloadedFiles);
|
||||
setFilesLoaded(true);
|
||||
@ -220,7 +220,7 @@ const FileManager = ({
|
||||
}
|
||||
} catch (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) {
|
||||
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 }}>
|
||||
<Group justify="space-between">
|
||||
<Text size="sm">
|
||||
{selectedFiles.length} file{selectedFiles.length > 1 ? 's' : ''} selected
|
||||
{selectedFiles.length} {t("fileManager.filesSelected", "files selected")}
|
||||
</Text>
|
||||
<Group>
|
||||
<Button
|
||||
@ -317,7 +317,7 @@ const FileManager = ({
|
||||
variant="light"
|
||||
onClick={() => setSelectedFiles([])}
|
||||
>
|
||||
Clear Selection
|
||||
{t("fileManager.clearSelection", "Clear Selection")}
|
||||
</Button>
|
||||
<Button
|
||||
size="xs"
|
||||
@ -325,7 +325,7 @@ const FileManager = ({
|
||||
onClick={handleOpenSelectedInEditor}
|
||||
disabled={selectedFiles.length === 0}
|
||||
>
|
||||
Open in File Editor
|
||||
{t("fileManager.openInFileEditor", "Open in File Editor")}
|
||||
</Button>
|
||||
</Group>
|
||||
</Group>
|
||||
@ -335,8 +335,8 @@ const FileManager = ({
|
||||
{/* Files Display */}
|
||||
{files.length === 0 ? (
|
||||
<FileUploadSelector
|
||||
title="Upload PDF Files"
|
||||
subtitle="Add files to your storage for easy access across tools"
|
||||
title={t("fileManager.title", "Upload PDF Files")}
|
||||
subtitle={t("fileManager.subtitle", "Add files to your storage for easy access across tools")}
|
||||
sharedFiles={[]} // FileManager is the source, so no shared files
|
||||
onFilesSelect={(uploadedFiles) => {
|
||||
// Handle multiple files - add to storage AND active set
|
||||
|
@ -123,28 +123,28 @@ const FilePickerModal = ({
|
||||
<Modal
|
||||
opened={opened}
|
||||
onClose={onClose}
|
||||
title="Select Files from Storage"
|
||||
title={t("fileUpload.selectFromStorage", "Select Files from Storage")}
|
||||
size="lg"
|
||||
scrollAreaComponent={ScrollArea.Autosize}
|
||||
>
|
||||
<Stack gap="md">
|
||||
{sharedFiles.length === 0 ? (
|
||||
<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>
|
||||
) : (
|
||||
<>
|
||||
{/* Selection controls */}
|
||||
<Group justify="space-between">
|
||||
<Text size="sm" c="dimmed">
|
||||
{sharedFiles.length} files available
|
||||
{sharedFiles.length} {t("fileUpload.filesAvailable", "files available")}
|
||||
</Text>
|
||||
<Group gap="xs">
|
||||
<Button size="xs" variant="light" onClick={selectAll}>
|
||||
Select All
|
||||
{t("pageEdit.selectAll", "Select All")}
|
||||
</Button>
|
||||
<Button size="xs" variant="light" onClick={selectNone}>
|
||||
Select None
|
||||
{t("pageEdit.deselectAll", "Select None")}
|
||||
</Button>
|
||||
</Group>
|
||||
</Group>
|
||||
@ -234,7 +234,7 @@ const FilePickerModal = ({
|
||||
{/* Selection summary */}
|
||||
{selectedFileIds.length > 0 && (
|
||||
<Text size="sm" c="blue" ta="center">
|
||||
{selectedFileIds.length} file{selectedFileIds.length > 1 ? 's' : ''} selected
|
||||
{selectedFileIds.length} {t("fileManager.filesSelected", "files selected")}
|
||||
</Text>
|
||||
)}
|
||||
</>
|
||||
@ -243,13 +243,16 @@ const FilePickerModal = ({
|
||||
{/* Action buttons */}
|
||||
<Group justify="flex-end" mt="md">
|
||||
<Button variant="light" onClick={onClose}>
|
||||
Cancel
|
||||
{t("close", "Cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleConfirm}
|
||||
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>
|
||||
</Group>
|
||||
</Stack>
|
||||
|
@ -24,8 +24,8 @@ interface FileUploadSelectorProps {
|
||||
}
|
||||
|
||||
const FileUploadSelector = ({
|
||||
title = "Select a file",
|
||||
subtitle = "Choose from storage or upload a new file",
|
||||
title,
|
||||
subtitle,
|
||||
showDropzone = true,
|
||||
sharedFiles = [],
|
||||
onFileSelect,
|
||||
@ -58,6 +58,12 @@ const FileUploadSelector = ({
|
||||
}
|
||||
}, [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 (
|
||||
<>
|
||||
<Stack align="center" gap="xl">
|
||||
@ -65,10 +71,10 @@ const FileUploadSelector = ({
|
||||
<Stack align="center" gap="md">
|
||||
<UploadFileIcon style={{ fontSize: 64 }} />
|
||||
<Text size="xl" fw={500}>
|
||||
{title}
|
||||
{displayTitle}
|
||||
</Text>
|
||||
<Text size="md" c="dimmed">
|
||||
{subtitle}
|
||||
{displaySubtitle}
|
||||
</Text>
|
||||
</Stack>
|
||||
|
||||
@ -81,11 +87,14 @@ const FileUploadSelector = ({
|
||||
disabled={disabled || sharedFiles.length === 0}
|
||||
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>
|
||||
|
||||
<Text size="md" c="dimmed">
|
||||
or
|
||||
{t("fileUpload.or", "or")}
|
||||
</Text>
|
||||
|
||||
{showDropzone ? (
|
||||
@ -99,10 +108,14 @@ const FileUploadSelector = ({
|
||||
<Center>
|
||||
<Stack align="center" gap="sm">
|
||||
<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 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>
|
||||
</Stack>
|
||||
</Center>
|
||||
@ -121,7 +134,8 @@ const FileUploadSelector = ({
|
||||
disabled={disabled}
|
||||
loading={loading}
|
||||
>
|
||||
Upload {allowMultiple ? 'Files' : 'File'}
|
||||
{t(allowMultiple ? "fileUpload.uploadFiles" : "fileUpload.uploadFile",
|
||||
allowMultiple ? "Upload Files" : "Upload File")}
|
||||
</Button>
|
||||
</Dropzone>
|
||||
)}
|
||||
|
@ -241,7 +241,7 @@ export default function HomePage() {
|
||||
onClick={() => setLeftPanelView('toolPicker')}
|
||||
className="text-sm"
|
||||
>
|
||||
← Back to Tools
|
||||
← {t("fileUpload.backToTools", "Back to Tools")}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@ -293,8 +293,11 @@ export default function HomePage() {
|
||||
) : (currentView != "fileManager") && !activeFiles[0] ? (
|
||||
<Container size="lg" p="xl" h="100%" style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||||
<FileUploadSelector
|
||||
title={currentView === "viewer" ? "Select a PDF to view" : "Select a PDF to edit"}
|
||||
subtitle="Choose a file from storage or upload a new PDF"
|
||||
title={currentView === "viewer"
|
||||
? 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}
|
||||
onFileSelect={(file) => {
|
||||
addToActiveFiles(file);
|
||||
|
Loading…
x
Reference in New Issue
Block a user