Translations for file management

This commit is contained in:
Reece
2025-06-20 21:46:37 +01:00
parent 215bb86a8e
commit cbc5616a39
5 changed files with 80 additions and 28 deletions

View File

@@ -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>

View File

@@ -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>
)}