Skip to content

internationalized added #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
895 changes: 527 additions & 368 deletions frontend/package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
},
"dependencies": {
"react-icons": "^5.4.0",
"react-collapsed": "^4.2.0"
"react-collapsed": "^4.2.0",
"react-intl": "^7.1.5"
},
"devDependencies": {
"@types/react": "^18.3.3",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ function App() {
height="100%"
width="100%"
initialPath=""
locale='en-US' // tr-TR, en-US
/>
</div>
</div>
Expand Down
10 changes: 6 additions & 4 deletions frontend/src/FileManager/Actions/Actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import UploadFileAction from "./UploadFile/UploadFile.action";
import PreviewFileAction from "./PreviewFile/PreviewFile.action";
import { useSelection } from "../../contexts/SelectionContext";
import { useShortcutHandler } from "../../hooks/useShortcutHandler";
import {injectIntl} from "react-intl";

const Actions = ({
fileUploadConfig,
Expand All @@ -17,6 +18,7 @@ const Actions = ({
filePreviewComponent,
acceptedFileTypes,
triggerAction,
intl
}) => {
const [activeAction, setActiveAction] = useState(null);
const { selectedFiles } = useSelection();
Expand All @@ -26,7 +28,7 @@ const Actions = ({

const actionTypes = {
uploadFile: {
title: "Upload",
title: intl.formatMessage({id: `upload`}),
component: (
<UploadFileAction
fileUploadConfig={fileUploadConfig}
Expand All @@ -39,7 +41,7 @@ const Actions = ({
width: "35%",
},
delete: {
title: "Delete",
title: intl.formatMessage({id: `delete`}),
component: <DeleteAction triggerAction={triggerAction} onDelete={onDelete} />,
width: "25%",
},
Expand All @@ -59,7 +61,7 @@ const Actions = ({
if (triggerAction.isActive) {
const actionType = triggerAction.actionType;
if (actionType === "previewFile") {
actionTypes[actionType].title = selectedFiles?.name ?? "Preview";
actionTypes[actionType].title = selectedFiles?.name ?? intl.formatMessage({id: `preview`});
}
setActiveAction(actionTypes[actionType]);
} else {
Expand All @@ -81,4 +83,4 @@ const Actions = ({
}
};

export default Actions;
export default injectIntl(Actions);
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import ErrorTooltip from "../../../components/ErrorTooltip/ErrorTooltip";
import { useFileNavigation } from "../../../contexts/FileNavigationContext";
import { useLayout } from "../../../contexts/LayoutContext";
import { validateApiCallback } from "../../../utils/validateApiCallback";
import {injectIntl} from "react-intl";

const maxNameLength = 220;

const CreateFolderAction = ({ filesViewRef, file, onCreateFolder, triggerAction }) => {
const CreateFolderAction = ({ filesViewRef, file, onCreateFolder, triggerAction, intl }) => {
const [folderName, setFolderName] = useState(file.name);
const [folderNameError, setFolderNameError] = useState(false);
const [folderErrorMessage, setFolderErrorMessage] = useState("");
Expand Down Expand Up @@ -49,7 +50,7 @@ const CreateFolderAction = ({ filesViewRef, file, onCreateFolder, triggerAction
if (invalidCharsRegex.test(e.key)) {
e.preventDefault();
setFolderErrorMessage(
"A file name can't contain any of the following characters: \\ / : * ? \" < > |"
intl.formatMessage({id: `folderErrorMessage`})+" \\ / : * ? \" < > |"
);
setFolderNameError(true);
} else {
Expand Down Expand Up @@ -80,7 +81,7 @@ const CreateFolderAction = ({ filesViewRef, file, onCreateFolder, triggerAction
});

if (alreadyExists) {
setFolderErrorMessage(`This destination already contains a folder named '${newFolderName}'.`);
setFolderErrorMessage(intl.formatMessage({id: `folderNameAlreadyContains`})+'${newFolderName}');
setFolderNameError(true);
outsideClick.ref.current?.focus();
outsideClick.ref.current?.select();
Expand All @@ -89,7 +90,7 @@ const CreateFolderAction = ({ filesViewRef, file, onCreateFolder, triggerAction
}

if (newFolderName === "") {
newFolderName = duplicateNameHandler("New Folder", true, syncedCurrPathFiles);
newFolderName = duplicateNameHandler(intl.formatMessage({id: `newFolder`}), true, syncedCurrPathFiles);
}

validateApiCallback(onCreateFolder, "onCreateFolder", newFolderName, currentFolder);
Expand Down Expand Up @@ -154,4 +155,4 @@ const CreateFolderAction = ({ filesViewRef, file, onCreateFolder, triggerAction
);
};

export default CreateFolderAction;
export default injectIntl(CreateFolderAction);
9 changes: 5 additions & 4 deletions frontend/src/FileManager/Actions/Delete/Delete.action.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import React, { useEffect, useState } from "react";
import Button from "../../../components/Button/Button";
import { useSelection } from "../../../contexts/SelectionContext";
import "./Delete.action.scss";
import {injectIntl} from "react-intl";

const DeleteAction = ({ triggerAction, onDelete }) => {
const DeleteAction = ({ triggerAction, onDelete, intl }) => {
const [deleteMsg, setDeleteMsg] = useState("");
const { selectedFiles, setSelectedFiles } = useSelection();

Expand All @@ -28,14 +29,14 @@ const DeleteAction = ({ triggerAction, onDelete }) => {
<p className="file-delete-confirm-text">{deleteMsg}</p>
<div className="file-delete-confirm-actions">
<Button type="secondary" onClick={() => triggerAction.close()}>
Cancel
{intl.formatMessage({id: `cancel`})}
</Button>
<Button type="danger" onClick={handleDeleting}>
Delete
{intl.formatMessage({id: `delete`})}
</Button>
</div>
</div>
);
};

export default DeleteAction;
export default injectIntl(DeleteAction);
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { MdOutlineFileDownload } from "react-icons/md";
import { useFileIcons } from "../../../hooks/useFileIcons";
import { FaRegFileAlt } from "react-icons/fa";
import "./PreviewFile.action.scss";
import {injectIntl} from "react-intl";

const imageExtensions = ["jpg", "jpeg", "png"];
const videoExtensions = ["mp4", "mov", "avi"];
Expand Down Expand Up @@ -66,7 +67,7 @@ const PreviewFileAction = ({ filePreviewPath, filePreviewComponent }) => {
<Button onClick={handleDownload} padding="0.45rem .9rem">
<div className="download-btn">
<MdOutlineFileDownload size={18} />
<span>Download</span>
<span>{intl.formatMessage({id: `download`})}</span>
</div>
</Button>
</div>
Expand Down Expand Up @@ -105,4 +106,4 @@ const PreviewFileAction = ({ filePreviewPath, filePreviewComponent }) => {
);
};

export default PreviewFileAction;
export default injectIntl(PreviewFileAction);
16 changes: 8 additions & 8 deletions frontend/src/FileManager/Actions/Rename/Rename.action.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import ErrorTooltip from "../../../components/ErrorTooltip/ErrorTooltip";
import { useFileNavigation } from "../../../contexts/FileNavigationContext";
import { useLayout } from "../../../contexts/LayoutContext";
import { validateApiCallback } from "../../../utils/validateApiCallback";
import {injectIntl} from "react-intl";

const maxNameLength = 220;

const RenameAction = ({ filesViewRef, file, onRename, triggerAction }) => {
const RenameAction = ({ filesViewRef, file, onRename, triggerAction, intl }) => {
const [renameFile, setRenameFile] = useState(file?.name);
const [renameFileWarning, setRenameFileWarning] = useState(false);
const [fileRenameError, setFileRenameError] = useState(false);
Expand Down Expand Up @@ -56,7 +57,7 @@ const RenameAction = ({ filesViewRef, file, onRename, triggerAction }) => {
if (invalidCharsRegex.test(e.key)) {
e.preventDefault();
setRenameErrorMessage(
"A file name can't contain any of the following characters: \\ / : * ? \" < > |"
intl.formatMessage({id: `folderErrorMessage`})+"\\ / : * ? \" < > |"
);
setFileRenameError(true);
} else {
Expand Down Expand Up @@ -91,7 +92,7 @@ const RenameAction = ({ filesViewRef, file, onRename, triggerAction }) => {
return;
} else if (currentPathFiles.some((file) => file.name === renameFile)) {
setFileRenameError(true);
setRenameErrorMessage(`This destination already contains a folder named '${renameFile}'.`);
setRenameErrorMessage(intl.formatMessage({id: `folderNameAlreadyContains`})+'${renameFile}');
outsideClick.setIsClicked(false);
return;
} else if (!file.isDirectory && !isConfirmed) {
Expand Down Expand Up @@ -187,8 +188,7 @@ const RenameAction = ({ filesViewRef, file, onRename, triggerAction }) => {
<div className="fm-rename-warning">
<IoWarningOutline size={70} color="orange" />
<div>
If you change a file name extension, the file might become unusable. Are you sure
you want to change it?
{intl.formatMessage({id: `fileNameChangeWarning`})}
</div>
</div>
</div>
Expand All @@ -208,7 +208,7 @@ const RenameAction = ({ filesViewRef, file, onRename, triggerAction }) => {
triggerAction.close();
}}
>
No
{intl.formatMessage({id: `no`})}
</Button>
<Button
type="danger"
Expand All @@ -217,7 +217,7 @@ const RenameAction = ({ filesViewRef, file, onRename, triggerAction }) => {
handleFileRenaming(true);
}}
>
Yes
{intl.formatMessage({id: `yes`})}
</Button>
</div>
</div>
Expand All @@ -226,4 +226,4 @@ const RenameAction = ({ filesViewRef, file, onRename, triggerAction }) => {
);
};

export default RenameAction;
export default injectIntl(RenameAction);
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import { getFileExtension } from "../../../utils/getFileExtension";
import { getDataSize } from "../../../utils/getDataSize";
import { useFiles } from "../../../contexts/FilesContext";
import "./UploadFile.action.scss";
import {injectIntl} from "react-intl";

const UploadFileAction = ({
fileUploadConfig,
maxFileSize,
acceptedFileTypes,
onFileUploading,
onFileUploaded,
intl
}) => {
const [files, setFiles] = useState([]);
const [isDragging, setIsDragging] = useState(false);
Expand All @@ -33,16 +35,16 @@ const UploadFileAction = ({
const checkFileError = (file) => {
if (acceptedFileTypes) {
const extError = !acceptedFileTypes.includes(getFileExtension(file.name));
if (extError) return "File type is not allowed.";
if (extError) return intl.formatMessage({id: `fileTypeNotAllowed`});
}

const fileExists = currentPathFiles.some(
(item) => item.name.toLowerCase() === file.name.toLowerCase() && !item.isDirectory
);
if (fileExists) return "File already exists.";
if (fileExists) return intl.formatMessage({id: `fileAlreadyExist`});

const sizeError = maxFileSize && file.size > maxFileSize;
if (sizeError) return `Maximum upload size is ${getDataSize(maxFileSize, 0)}.`;
if (sizeError) return intl.formatMessage({id: `maxUploadSize`})+" "+getDataSize(maxFileSize, 0);
};

const setSelectedFiles = (selectedFiles) => {
Expand Down Expand Up @@ -110,12 +112,12 @@ const UploadFileAction = ({
>
<div className="input-text">
<AiOutlineCloudUpload size={30} />
<span>Drag files to upload</span>
<span>{intl.formatMessage({id: `dragFileToUpload`})}</span>
</div>
</div>
<div className="btn-choose-file">
<Button padding="0" onKeyDown={handleChooseFileKeyDown}>
<label htmlFor="chooseFile">Choose File</label>
<label htmlFor="chooseFile">{intl.formatMessage({id: `chooseFile`})}</label>
<input
ref={fileInputRef}
type="file"
Expand All @@ -137,7 +139,7 @@ const UploadFileAction = ({
<Loader loading={true} className="upload-loading" />
</>
) : (
<h2>Completed</h2>
<h2>{intl.formatMessage({id: `completed`})}</h2>
)}
</div>
<ul>
Expand All @@ -160,4 +162,4 @@ const UploadFileAction = ({
);
};

export default UploadFileAction;
export default injectIntl(UploadFileAction);
10 changes: 6 additions & 4 deletions frontend/src/FileManager/Actions/UploadFile/UploadItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getDataSize } from "../../../utils/getDataSize";
import { FaRegCheckCircle } from "react-icons/fa";
import { IoMdRefresh } from "react-icons/io";
import { useFiles } from "../../../contexts/FilesContext";
import {injectIntl} from "react-intl";

const UploadItem = ({
index,
Expand All @@ -17,6 +18,7 @@ const UploadItem = ({
fileUploadConfig,
onFileUploaded,
handleFileRemove,
intl
}) => {
const [uploadProgress, setUploadProgress] = useState(0);
const [isUploaded, setIsUploaded] = useState(false);
Expand All @@ -34,7 +36,7 @@ const UploadItem = ({
}));
const error = {
type: "upload",
message: "Upload failed.",
message: intl.formatMessage({id: `uploadFail`}),
response: {
status: xhr.status,
statusText: xhr.statusText,
Expand Down Expand Up @@ -173,13 +175,13 @@ const UploadItem = ({
<span className="file-size">{getDataSize(fileData.file?.size)}</span>
</div>
{isUploaded ? (
<FaRegCheckCircle title="Uploaded" className="upload-success" />
<FaRegCheckCircle title={intl.formatMessage({id: `uploaded`})} className="upload-success" />
) : isCanceled || uploadFailed ? (
<IoMdRefresh className="retry-upload" title="Retry" onClick={handleRetry} />
) : (
<div
className="rm-file"
title={`${!!fileData.error ? "Remove" : "Abort Upload"}`}
title={`${!!fileData.error ? intl.formatMessage({id: `remove`}) : intl.formatMessage({id: `abortUpload`})}`}
onClick={!!fileData.error ? () => handleFileRemove(index) : handleAbortUpload}
>
<AiOutlineClose />
Expand All @@ -197,4 +199,4 @@ const UploadItem = ({
);
};

export default UploadItem;
export default injectIntl(UploadItem);
9 changes: 5 additions & 4 deletions frontend/src/FileManager/BreadCrumb/BreadCrumb.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { MdHome, MdMoreHoriz, MdOutlineNavigateNext } from "react-icons/md";
import { useFileNavigation } from "../../contexts/FileNavigationContext";
import { useDetectOutsideClick } from "../../hooks/useDetectOutsideClick";
import "./BreadCrumb.scss";
import {injectIntl} from "react-intl";

const BreadCrumb = () => {
const BreadCrumb = ({intl}) => {
const [folders, setFolders] = useState([]);
const [hiddenFolders, setHiddenFolders] = useState([]);
const [hiddenFoldersWidth, setHiddenFoldersWidth] = useState([]);
Expand All @@ -23,7 +24,7 @@ const BreadCrumb = () => {
let path = "";
return currentPath?.split("/").map((item) => {
return {
name: item || "Home",
name: item || intl.formatMessage({id: `home`}),
path: item === "" ? item : (path += `/${item}`),
};
});
Expand Down Expand Up @@ -92,7 +93,7 @@ const BreadCrumb = () => {
className="folder-name folder-name-btn"
onClick={() => setShowHiddenFolders(true)}
ref={moreBtnRef}
title="Show more folders"
title={intl.formatMessage({id: `showMoreFolder`})}
>
<MdMoreHoriz size={22} className="hidden-folders" />
</button>
Expand Down Expand Up @@ -122,4 +123,4 @@ const BreadCrumb = () => {

BreadCrumb.displayName = "BreadCrumb";

export default BreadCrumb;
export default injectIntl(BreadCrumb);
Loading