Apply i18n

This commit is contained in:
Takeshi Kimata
2024-05-04 16:15:29 +09:00
parent 9c390ef305
commit 520f6a98dd
12 changed files with 181 additions and 44 deletions

View File

@@ -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<RunType>(defaultTestRun);
const [folders, setFolders] = useState([]);
const [runCases, setRunCases] = useState<RunCaseType[]>([]);
@@ -338,13 +340,13 @@ export default function RunEditor({ projectId, runId, locale }: Props) {
startContent={<CopyPlus size={16} />}
onClick={() => handleBulkIncludeExcludeCases(true)}
>
Include selected cases in run
{messages.includeInRun}
</DropdownItem>
<DropdownItem
startContent={<CopyMinus size={16} />}
onClick={() => handleBulkIncludeExcludeCases(false)}
>
Exclude selected cases from run
{messages.excludeFromRun}
</DropdownItem>
</DropdownMenu>
</Dropdown>
@@ -385,6 +387,7 @@ export default function RunEditor({ projectId, runId, locale }: Props) {
onExcludeCase={(excludeCaseId) =>
handleIncludeExcludeCase(false, excludeCaseId)
}
messages={messages}
/>
</div>
</div>

View File

@@ -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<SortDescriptor>({
column: "id",
direction: "ascending",
@@ -102,7 +105,7 @@ export default function TestCaseSelector({
color={isIncluded ? priorities[cellValue].color : "#d4d4d8"}
fill={isIncluded ? priorities[cellValue].color : "#d4d4d8"}
/>
<div className="ms-3">{priorities[cellValue].name}</div>
<div className="ms-3">{messages[priorities[cellValue].uid]}</div>
</div>
);
case "runStatus":
@@ -120,7 +123,7 @@ export default function TestCaseSelector({
endContent={isIncluded && <ChevronDown size={16} />}
>
<span className="w-12">
{isIncluded && testRunCaseStatus[cellValue].name}
{isIncluded && messages[testRunCaseStatus[cellValue].uid]}
</span>
</Button>
</DropdownTrigger>
@@ -131,7 +134,7 @@ export default function TestCaseSelector({
startContent={renderStatusIcon(runCaseStatus.uid)}
onPress={() => onStatusChange(testCase.id, index)}
>
{runCaseStatus.name}
{messages[runCaseStatus.uid]}
</DropdownItem>
))}
</DropdownMenu>
@@ -151,14 +154,14 @@ export default function TestCaseSelector({
isDisabled={testCase.isIncluded}
onPress={() => onIncludeCase(testCase.id)}
>
Include in run
{messages.includeInRun}
</DropdownItem>
<DropdownItem
startContent={<CopyMinus size={16} />}
isDisabled={!testCase.isIncluded}
onPress={() => onExcludeCase(testCase.id)}
>
Exclude from run
{messages.excludeFromRun}
</DropdownItem>
</DropdownMenu>
</Dropdown>
@@ -215,7 +218,7 @@ export default function TestCaseSelector({
</TableColumn>
)}
</TableHeader>
<TableBody emptyContent={"No cases found"} items={sortedItems}>
<TableBody emptyContent={messages.noCasesFound} items={sortedItems}>
{(item) => (
<TableRow
key={item.id}

View File

@@ -1,14 +1,37 @@
import RunEditor from "./RunEditor";
import { useTranslations } from "next-intl";
export default function Page({
params,
}: {
params: { projectId: string; runId: string; locale: string };
}) {
const t = useTranslations("Runs");
const messages = {
id: t("id"),
title: t("title"),
priority: t("priority"),
actions: t("actions"),
status: t("status"),
critical: t("critical"),
high: t("high"),
medium: t("medium"),
low: t("low"),
untested: t("untested"),
passed: t("passed"),
failed: t("failed"),
retest: t("retest"),
skipped: t("skipped"),
includeInRun: t("include_in_run"),
excludeFromRun: t("exclude_from_run"),
noCasesFound: t("no_cases_found"),
};
return (
<RunEditor
projectId={params.projectId}
runId={params.runId}
messages={messages}
locale={params.locale}
/>
);