From 520f6a98dd259bb973c0c844b4c7b438bcbc637f Mon Sep 17 00:00:00 2001
From: Takeshi Kimata <117462761+kimatata@users.noreply.github.com>
Date: Sat, 4 May 2024 16:15:29 +0900
Subject: [PATCH] Apply i18n
---
frontend/config/selection.ts | 22 +++++++-----
frontend/messages/en.json | 34 +++++++++++++++++--
frontend/messages/ja.json | 32 ++++++++++++++++-
.../[folderId]/cases/TestCaseTable.tsx | 2 +-
.../[folderId]/cases/[caseId]/CaseEditor.tsx | 5 +--
.../[folderId]/cases/[caseId]/page.tsx | 10 ++++++
.../folders/[folderId]/cases/page.tsx | 15 +++-----
.../[projectId]/runs/[runId]/RunEditor.tsx | 9 +++--
.../runs/[runId]/TestCaseSelector.tsx | 31 +++++++++--------
.../[projectId]/runs/[runId]/page.tsx | 23 +++++++++++++
frontend/types/case.ts | 14 +++++++-
frontend/types/run.ts | 28 ++++++++++++++-
12 files changed, 181 insertions(+), 44 deletions(-)
diff --git a/frontend/config/selection.ts b/frontend/config/selection.ts
index b74769d..9192003 100644
--- a/frontend/config/selection.ts
+++ b/frontend/config/selection.ts
@@ -1,8 +1,8 @@
const priorities = [
- { name: "Critical", uid: "critical", color: "#d00002" },
- { name: "High", uid: "high", color: "#ee6b4e" },
- { name: "Medium", uid: "medium", color: "#fccb69" },
- { name: "Low", uid: "low", color: "#0b62e8" },
+ { uid: "critical", color: "#d00002" },
+ { uid: "high", color: "#ee6b4e" },
+ { uid: "medium", color: "#fccb69" },
+ { uid: "low", color: "#0b62e8" },
];
const testTypes = [
@@ -43,11 +43,15 @@ const testRunStatus = [
];
const testRunCaseStatus = [
- { name: "Untested", uid: "untested", color: "primary", chartColor: "#e5e7eb" },
- { name: "Passed", uid: "passed", color: "success", chartColor: "#059669" },
- { name: "Failed", uid: "failed", color: "danger", chartColor: "#f87171" },
- { name: "Retest", uid: "retest", color: "warning", chartColor: "#fbbf24" },
- { name: "Skipped", uid: "skipped", color: "primary", chartColor: "#4b5563" },
+ {
+ uid: "untested",
+ color: "primary",
+ chartColor: "#e5e7eb",
+ },
+ { uid: "passed", color: "success", chartColor: "#059669" },
+ { uid: "failed", color: "danger", chartColor: "#f87171" },
+ { uid: "retest", color: "warning", chartColor: "#fbbf24" },
+ { uid: "skipped", color: "primary", chartColor: "#4b5563" },
];
export {
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index 3c049fb..89f023d 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -40,11 +40,41 @@
"Cases": {
"test_cases": "Test Cases",
"id": "ID",
- "name": "Name",
+ "title": "Title",
"priority": "Priority",
"actions": "Actions",
"delete_case": "Delete test case",
"delete": "Delete",
- "new_test_case": "New Test Case"
+ "new_test_case": "New Test Case",
+ "status": "Status",
+ "critical": "Critical",
+ "high": "High",
+ "medium": "Medium",
+ "low": "Low"
+ },
+ "Case": {
+ "critical": "Critical",
+ "high": "High",
+ "medium": "Medium",
+ "low": "Low"
+ },
+ "Runs": {
+ "id": "ID",
+ "title": "Title",
+ "priority": "Priority",
+ "status": "Status",
+ "actions": "Actions",
+ "critical": "Critical",
+ "high": "High",
+ "medium": "Medium",
+ "low": "Low",
+ "untested": "Untested",
+ "passed": "Passed",
+ "failed": "Failed",
+ "retest": "Retest",
+ "skipped": "Skipped",
+ "include_in_run": "Include in run",
+ "exclude_from_run": "Exclude from run",
+ "no_cases_found": "No cases found"
}
}
diff --git a/frontend/messages/ja.json b/frontend/messages/ja.json
index 142d36a..064667c 100644
--- a/frontend/messages/ja.json
+++ b/frontend/messages/ja.json
@@ -45,6 +45,36 @@
"actions": "アクション",
"delete_case": "テストケースを削除",
"delete": "削除",
- "new_test_case": "新規テストケース"
+ "new_test_case": "新規テストケース",
+ "status": "ステータス",
+ "critical": "致",
+ "high": "高",
+ "medium": "中",
+ "low": "低"
+ },
+ "Case": {
+ "critical": "致",
+ "high": "高",
+ "medium": "中",
+ "low": "低"
+ },
+ "Runs": {
+ "id": "ID",
+ "title": "タイトル",
+ "priority": "優先度",
+ "status": "ステータス",
+ "actions": "アクション",
+ "critical": "致",
+ "high": "高",
+ "medium": "中",
+ "low": "低",
+ "untested": "未実行",
+ "passed": "成功",
+ "failed": "失敗",
+ "retest": "再テスト",
+ "skipped": "スキップ",
+ "include_in_run": "テストランに含める",
+ "exclude_from_run": "テストランから除外する",
+ "no_cases_found": "テストケースが見つかりません"
}
}
diff --git a/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/TestCaseTable.tsx b/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/TestCaseTable.tsx
index 9bdce23..bace083 100644
--- a/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/TestCaseTable.tsx
+++ b/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/TestCaseTable.tsx
@@ -107,7 +107,7 @@ export default function TestCaseTable({
color={priorities[cellValue].color}
fill={priorities[cellValue].color}
/>
-
{priorities[cellValue].name}
+ {messages[priorities[cellValue].uid]}
);
case "actions":
diff --git a/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/[caseId]/CaseEditor.tsx b/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/[caseId]/CaseEditor.tsx
index 51d156d..ba9ee58 100644
--- a/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/[caseId]/CaseEditor.tsx
+++ b/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/[caseId]/CaseEditor.tsx
@@ -14,7 +14,7 @@ import { Save, Plus, ArrowLeft, ArrowUpFromLine, Circle } from "lucide-react";
import { priorities, testTypes, templates } from "@/config/selection";
import CaseStepsEditor from "./CaseStepsEditor";
import CaseAttachmentsEditor from "./CaseAttachmentsEditor";
-import { CaseType, AttachmentType } from "@/types/case";
+import { CaseType, AttachmentType, CaseMessages } from "@/types/case";
import { fetchCase, updateCase } from "../caseControl";
import { fetchCreateStep, fetchDeleteStep } from "./stepControl";
import {
@@ -44,6 +44,7 @@ export default function CaseEditor({
projectId: string;
folderId: string;
caseId: string;
+ messages: CaseMessages;
locale: string;
};
}) {
@@ -253,7 +254,7 @@ export default function CaseEditor({
>
{priorities.map((priority, index) => (
- {priority.name}
+ {params.messages[priority.uid]}
))}
diff --git a/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/[caseId]/page.tsx b/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/[caseId]/page.tsx
index a465505..e6d0f29 100644
--- a/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/[caseId]/page.tsx
+++ b/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/[caseId]/page.tsx
@@ -1,4 +1,5 @@
import CaseEditor from "./CaseEditor";
+import { useTranslations } from "next-intl";
export default function Page({
params,
@@ -10,12 +11,21 @@ export default function Page({
locale: string;
};
}) {
+ const t = useTranslations("Case");
+ const messages = {
+ critical: t("critical"),
+ high: t("high"),
+ medium: t("medium"),
+ low: t("low"),
+ };
+
return (
diff --git a/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/page.tsx b/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/page.tsx
index c62ec2f..50f14ec 100644
--- a/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/page.tsx
+++ b/frontend/src/app/[locale]/projects/[projectId]/folders/[folderId]/cases/page.tsx
@@ -9,10 +9,6 @@ export default function Page({
const t = useTranslations("Cases");
const messages = {
testCases: t("test_cases"),
- // folder: t("folder"),
- // newFolder: t("new_folder"),
-
- // deleteFolder: t("delete_folder"),
id: t("id"),
title: t("title"),
priority: t("priority"),
@@ -20,12 +16,11 @@ export default function Page({
deleteCase: t("delete_case"),
delete: t("delete"),
newTestCase: t("new_test_case"),
- // projectName: t("folder_name"),
- // projectDetail: t("folder_detail"),
- // close: t("close"),
- // create: t("create"),
- // update: t("update"),
- // pleaseEnter: t("please_enter"),
+ status: t("status"),
+ critical: t("critical"),
+ high: t("high"),
+ medium: t("medium"),
+ low: t("low"),
};
return (
diff --git a/frontend/src/app/[locale]/projects/[projectId]/runs/[runId]/RunEditor.tsx b/frontend/src/app/[locale]/projects/[projectId]/runs/[runId]/RunEditor.tsx
index 969e291..cb394ac 100644
--- a/frontend/src/app/[locale]/projects/[projectId]/runs/[runId]/RunEditor.tsx
+++ b/frontend/src/app/[locale]/projects/[projectId]/runs/[runId]/RunEditor.tsx
@@ -35,6 +35,7 @@ import {
RunCaseType,
RunCaseInfoType,
RunStatusCountType,
+ RunsMessages,
} from "@/types/run";
import { CaseType } from "@/types/case";
import { FolderType } from "@/types/folder";
@@ -63,10 +64,11 @@ const defaultTestRun = {
type Props = {
projectId: string;
runId: string;
+ messages: RunsMessages;
locale: string;
};
-export default function RunEditor({ projectId, runId, locale }: Props) {
+export default function RunEditor({ projectId, runId, messages, locale }: Props) {
const [testRun, setTestRun] = useState(defaultTestRun);
const [folders, setFolders] = useState([]);
const [runCases, setRunCases] = useState([]);
@@ -338,13 +340,13 @@ export default function RunEditor({ projectId, runId, locale }: Props) {
startContent={}
onClick={() => handleBulkIncludeExcludeCases(true)}
>
- Include selected cases in run
+ {messages.includeInRun}
}
onClick={() => handleBulkIncludeExcludeCases(false)}
>
- Exclude selected cases from run
+ {messages.excludeFromRun}
@@ -385,6 +387,7 @@ export default function RunEditor({ projectId, runId, locale }: Props) {
onExcludeCase={(excludeCaseId) =>
handleIncludeExcludeCase(false, excludeCaseId)
}
+ messages={messages}
/>
diff --git a/frontend/src/app/[locale]/projects/[projectId]/runs/[runId]/TestCaseSelector.tsx b/frontend/src/app/[locale]/projects/[projectId]/runs/[runId]/TestCaseSelector.tsx
index bd093dd..dd44a0a 100644
--- a/frontend/src/app/[locale]/projects/[projectId]/runs/[runId]/TestCaseSelector.tsx
+++ b/frontend/src/app/[locale]/projects/[projectId]/runs/[runId]/TestCaseSelector.tsx
@@ -27,14 +27,7 @@ import {
} from "lucide-react";
import { priorities, testRunCaseStatus } from "@/config/selection";
import { CaseType } from "@/types/case";
-
-const headerColumns = [
- { name: "ID", uid: "id", sortable: true },
- { name: "Title", uid: "title", sortable: true },
- { name: "Priority", uid: "priority", sortable: true },
- { name: "Status", uid: "runStatus", sortable: true },
- { name: "Actions", uid: "actions" },
-];
+import { RunsMessages } from "@/types/run";
type Props = {
cases: CaseType[];
@@ -43,6 +36,7 @@ type Props = {
onStatusChange: (changeCaseId: number, status: number) => {};
onIncludeCase: (includeCaseId: number) => {};
onExcludeCase: (excludeCaseId: number) => {};
+ messages: RunsMessages;
};
export default function TestCaseSelector({
@@ -52,7 +46,16 @@ export default function TestCaseSelector({
onStatusChange,
onIncludeCase,
onExcludeCase,
+ messages,
}: Props) {
+ const headerColumns = [
+ { name: messages.id, uid: "id", sortable: true },
+ { name: messages.title, uid: "title", sortable: true },
+ { name: messages.priority, uid: "priority", sortable: true },
+ { name: messages.status, uid: "runStatus", sortable: true },
+ { name: messages.actions, uid: "actions" },
+ ];
+
const [sortDescriptor, setSortDescriptor] = useState({
column: "id",
direction: "ascending",
@@ -102,7 +105,7 @@ export default function TestCaseSelector({
color={isIncluded ? priorities[cellValue].color : "#d4d4d8"}
fill={isIncluded ? priorities[cellValue].color : "#d4d4d8"}
/>
- {priorities[cellValue].name}
+ {messages[priorities[cellValue].uid]}
);
case "runStatus":
@@ -120,7 +123,7 @@ export default function TestCaseSelector({
endContent={isIncluded && }
>
- {isIncluded && testRunCaseStatus[cellValue].name}
+ {isIncluded && messages[testRunCaseStatus[cellValue].uid]}
@@ -131,7 +134,7 @@ export default function TestCaseSelector({
startContent={renderStatusIcon(runCaseStatus.uid)}
onPress={() => onStatusChange(testCase.id, index)}
>
- {runCaseStatus.name}
+ {messages[runCaseStatus.uid]}
))}
@@ -151,14 +154,14 @@ export default function TestCaseSelector({
isDisabled={testCase.isIncluded}
onPress={() => onIncludeCase(testCase.id)}
>
- Include in run
+ {messages.includeInRun}
}
isDisabled={!testCase.isIncluded}
onPress={() => onExcludeCase(testCase.id)}
>
- Exclude from run
+ {messages.excludeFromRun}
@@ -215,7 +218,7 @@ export default function TestCaseSelector({
)}
-
+
{(item) => (
);
diff --git a/frontend/types/case.ts b/frontend/types/case.ts
index 280c82a..4df6cd9 100644
--- a/frontend/types/case.ts
+++ b/frontend/types/case.ts
@@ -58,6 +58,18 @@ export type CasesMessages = {
deleteCase: string;
delete: string;
newTestCase: string;
+ status: string;
+ critical: string;
+ high: string;
+ medium: string;
+ low: string;
};
-export { CaseType, StepType, AttachmentType, CasesMessages };
+export type CaseMessages = {
+ critical: string;
+ high: string;
+ medium: string;
+ low: string;
+};
+
+export { CaseType, StepType, AttachmentType, CasesMessages, CaseMessages };
diff --git a/frontend/types/run.ts b/frontend/types/run.ts
index 50a5a74..df7f2a7 100644
--- a/frontend/types/run.ts
+++ b/frontend/types/run.ts
@@ -26,4 +26,30 @@ type RunStatusCountType = {
count: number;
};
-export { RunType, RunCaseType, RunCaseInfoType, RunStatusCountType };
+export type RunsMessages = {
+ id: string;
+ title: string;
+ priority: string;
+ status: string;
+ actions: string;
+ critical: string;
+ high: string;
+ medium: string;
+ low: string;
+ untested: string;
+ passed: string;
+ failed: string;
+ retest: string;
+ skipped: string;
+ includeInRun: string;
+ excludeFromRun: string;
+ noCasesFound: string;
+};
+
+export {
+ RunType,
+ RunCaseType,
+ RunCaseInfoType,
+ RunStatusCountType,
+ RunsMessages,
+};