Skip to content

Commit

Permalink
Merge pull request #23 from SARDONYX-sard/feature/implement-i18n-system
Browse files Browse the repository at this point in the history
Feature/implement i18n system
  • Loading branch information
SARDONYX-sard authored Nov 5, 2023
2 parents 1535e9c + fe897c7 commit 27f755b
Show file tree
Hide file tree
Showing 26 changed files with 722 additions and 441 deletions.
2 changes: 1 addition & 1 deletion frontend/next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
distDir: "../out",
output: "export",
reactStrictMode: true,
swcMinify: true,
};

Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "@/app/globals.css";
import "@/utils/translation";
import Loading from "@/components/pages/loading";
import React from "react";
import dynamic from "next/dynamic";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Converter from "../components/pages/converter";
import Converter from "@/components/pages/converter";

/**
* # Root page (URL: /).
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/components/buttons/convert_btn.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import ConvertIcon from "@mui/icons-material/Transform";
import LoadingButton from "@mui/lab/LoadingButton";
import { useTranslation } from "react-i18next";

type Props = {
type Props = Readonly<{
loading: boolean;
setLoading: (loading: boolean) => void;
};
}>;

/**
*
* Icon ref
* - https://mui.com/material-ui/material-icons/
*/
export default function ConvertButton({ loading, setLoading }: Props) {
const { t } = useTranslation();

return (
<LoadingButton
type="submit"
Expand All @@ -22,7 +25,7 @@ export default function ConvertButton({ loading, setLoading }: Props) {
variant="contained"
onChange={() => setLoading(true)}
>
<span>{loading ? "Converting..." : "Convert"}</span>
<span>{loading ? t("converting-btn") : t("convert-btn")}</span>
</LoadingButton>
);
}
5 changes: 4 additions & 1 deletion frontend/src/components/buttons/log_file_btn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import toast from "react-hot-toast";
import { Button } from "@mui/material";
import { FileOpen } from "@mui/icons-material";
import { openLogFile } from "@/tauri_cmd";
import { useTranslation } from "react-i18next";

export const LogFileButton = () => {
const { t } = useTranslation();

return (
<Button
sx={{
Expand All @@ -16,7 +19,7 @@ export const LogFileButton = () => {
type="button"
variant="outlined"
>
Open log
{t("open-log-btn")}
</Button>
);
};
8 changes: 5 additions & 3 deletions frontend/src/components/buttons/path_selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import FolderOpenIcon from "@mui/icons-material/FolderOpen";
import toast from "react-hot-toast";
import { Button } from "@mui/material";
import { openPath } from "../../tauri_cmd";
import { useTranslation } from "react-i18next";

type Props = {
type Props = Readonly<{
path: string;
isDir?: boolean;
setValue: (value: string) => void;
};
}>;

export function SelectPathButton({ path, isDir = false, setValue }: Props) {
const { t } = useTranslation();
const handleClick = async () => {
openPath(path, setValue, isDir).catch((e) => toast.error(`${e}`));
};
Expand All @@ -26,7 +28,7 @@ export function SelectPathButton({ path, isDir = false, setValue }: Props) {
type="button"
variant="outlined"
>
Select
{t("select-btn")}
</Button>
);
}
23 changes: 9 additions & 14 deletions frontend/src/components/buttons/remove_oar_btn.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import { removeOarDir } from "@/tauri_cmd";
import toast from "react-hot-toast";
import DeleteIcon from "@mui/icons-material/Delete";
import Button from "@mui/material/Button";
import DeleteIcon from "@mui/icons-material/Delete";
import Tooltip from "@mui/material/Tooltip";
import toast from "react-hot-toast";
import { removeOarDir } from "@/tauri_cmd";
import { useTranslation } from "react-i18next";

type Props = {
darPath: string;
oarPath: string;
};

export const RemoveOarBtn = ({ darPath, oarPath }: Props) => {
const { t } = useTranslation();
return (
<Tooltip
title={
<p>
Find and delete OAR dir from &quot;DAR(src) Directory*&quot; or
&quot;OAR(dist) Directory&quot;.
</p>
}
>
<Tooltip title={<p>{t("remove-oar-tooltip")}</p>}>
<Button
type="button"
sx={{
Expand All @@ -30,19 +25,19 @@ export const RemoveOarBtn = ({ darPath, oarPath }: Props) => {
onClick={async () => {
try {
await removeOarDir(darPath);
toast.success("Removed OAR directory.");
toast.success(t("remove-oar-success"));
} catch (_) {
try {
await removeOarDir(oarPath);
toast.success("Removed OAR directory.");
toast.success(t("remove-oar-success"));
} catch (e) {
toast.error(`${e}`);
}
}
}}
startIcon={<DeleteIcon />}
>
Remove OAR
{t("remove-oar-btn")}
</Button>
</Tooltip>
);
Expand Down
13 changes: 5 additions & 8 deletions frontend/src/components/buttons/unhide_dar_btn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@ import Button from "@mui/material/Button";
import { restoreDarDir } from "@/tauri_cmd";
import toast from "react-hot-toast";
import VisibilityIcon from "@mui/icons-material/Visibility";
import { useTranslation } from "react-i18next";

type Props = {
path: string;
};

export const UnhideDarBtn = ({ path }: Props) => {
const { t } = useTranslation();

return (
<Tooltip
title={
<p>
Unhide the directory hidden by &quot;Hide DAR&quot;.(For MO2 user)
</p>
}
>
<Tooltip title={<p>{t("unhide-dar-btn-tooltip")}</p>}>
<Button
type="button"
sx={{
Expand All @@ -34,7 +31,7 @@ export const UnhideDarBtn = ({ path }: Props) => {
}}
startIcon={<VisibilityIcon />}
>
Unhide DAR
{t("unhide-dar-btn")}
</Button>
</Tooltip>
);
Expand Down
Loading

0 comments on commit 27f755b

Please sign in to comment.