From 55a9d799650880a9a66ac2772f543e7c172eaf23 Mon Sep 17 00:00:00 2001 From: fly6516 Date: Mon, 14 Apr 2025 16:47:13 +0800 Subject: [PATCH] feat: add missing i18n in sign up and login in page,add i18n in table.tsx --- messages/en.json | 34 ++++++++++- messages/zh.json | 34 ++++++++++- src/components/credentials-sign-in-form.tsx | 2 +- src/components/credentials-sign-up-form.tsx | 2 +- .../dashboard/admin/problemset/table.tsx | 61 ++++++++++--------- 5 files changed, 98 insertions(+), 35 deletions(-) diff --git a/messages/en.json b/messages/en.json index 96e7a8b..23b105c 100644 --- a/messages/en.json +++ b/messages/en.json @@ -4,7 +4,8 @@ "Enter your email below to sign in to your account": "Enter your email below to sign in to your account", "Or": "Or", "Don't have an account?": "Don't have an account?", - "Sign up": "Sign up" + "sign-up": "Sign up", + "signing-in": "Signing In..." }, "sign-up-form": { "title": "Hello world!", @@ -12,7 +13,8 @@ "sign-up-to-your-account": "Sign up to your account", "or": "Or", "already-have-an-account": "Already have an account?", - "sign-in": "Sign in" + "sign-in": "Sign in", + "creating-account": "Creating Account..." }, "appearance-settings": { "choose-a-theme": "Choose a theme", @@ -71,5 +73,33 @@ "test": { "case": "Case", "failed-to-submit-the-form-please-try-again": "Failed to submit the form. Please try again." + }, + "problemset": { + "select-all": "Select all", + "select-row": "Select row", + "title": "Title", + "difficulty": "Difficulty", + "actions": "Actions", + "displayid-or-title": "DisplayId or Title...", + "filter-by-displayid-or-title": "Filter by displayId or title", + "clear-filter": "Clear filter", + "filters": "Filters", + "view": "View", + "toggle-columns": "Toggle columns", + "delete": "Delete", + "are-you-absolutely-sure": "Are you absolutely sure?", + "this-action-cannot-be-undone-this-will-permanently-delete": "This action cannot be undone. This will permanently delete", + "cancel": "Cancel", + "add-problem": "Add Problem", + "enter": "Enter", + "no-results": "No results.", + "rows-per-page": "Rows per page", + "select-number-of-results": "Select number of results", + "go-to-first-page": "Go to first page", + "go-to-previous-page": "Go to previous page", + "go-to-next-page": "Go to next page", + "go-to-last-page": "Go to last page", + "edit-item": "Edit item", + "edit": "Edit" } } diff --git a/messages/zh.json b/messages/zh.json index f90e32c..ca296e0 100644 --- a/messages/zh.json +++ b/messages/zh.json @@ -4,7 +4,8 @@ "Enter your email below to sign in to your account": "在下方输入你的邮箱以登录", "Or": "或", "Don't have an account?": "没有帐户?", - "Sign up": "注册" + "sign-up": "注册", + "signing-in": "正在登录。。。" }, "sign-up-form": { "title": "Hello world!", @@ -12,7 +13,8 @@ "enter-your-email-below-to-sign-up-to-your-account": "在下面输入您的电子邮件以注册您的帐户", "or": "或", "sign-in": "登录", - "sign-up-to-your-account": "注册您的帐户" + "sign-up-to-your-account": "注册您的帐户", + "creating-account": "正在创建帐户。。。" }, "appearance-settings": { "dark": "暗", @@ -71,5 +73,33 @@ "test": { "case": "样例", "failed-to-submit-the-form-please-try-again": "提交失败。请重试。" + }, + "problemset": { + "actions": "行动", + "add-problem": "添加问题", + "are-you-absolutely-sure": "你真的确定吗?", + "cancel": "取消", + "clear-filter": "清除过滤器", + "enter": "进入", + "filter-by-displayid-or-title": "按显示ID或标题筛选", + "filters": "过滤器", + "go-to-first-page": "转到第一页", + "go-to-last-page": "转到最后一页", + "select-number-of-results": "选择结果数量", + "select-row": "选定行", + "this-action-cannot-be-undone-this-will-permanently-delete": "此操作无法撤消。这将永久删除", + "title": "名称", + "toggle-columns": "切换列", + "delete": "删除", + "difficulty": "难度", + "displayid-or-title": "显示ID或标题。。。", + "edit": "编辑", + "edit-item": "编辑项目", + "view": "视图", + "go-to-next-page": "转到下一页", + "go-to-previous-page": "转到上一页", + "no-results": "没有结果。", + "rows-per-page": "每页行数", + "select-all": "选择全部" } } diff --git a/src/components/credentials-sign-in-form.tsx b/src/components/credentials-sign-in-form.tsx index 10bcb8c..9efc329 100644 --- a/src/components/credentials-sign-in-form.tsx +++ b/src/components/credentials-sign-in-form.tsx @@ -112,7 +112,7 @@ export function CredentialsSignInForm() { /> diff --git a/src/components/credentials-sign-up-form.tsx b/src/components/credentials-sign-up-form.tsx index 2948dc9..741f687 100644 --- a/src/components/credentials-sign-up-form.tsx +++ b/src/components/credentials-sign-up-form.tsx @@ -117,7 +117,7 @@ export function CredentialsSignUpForm() { /> diff --git a/src/components/features/dashboard/admin/problemset/table.tsx b/src/components/features/dashboard/admin/problemset/table.tsx index d225487..4fb9399 100644 --- a/src/components/features/dashboard/admin/problemset/table.tsx +++ b/src/components/features/dashboard/admin/problemset/table.tsx @@ -83,9 +83,12 @@ import { Checkbox } from "@/components/ui/checkbox"; import { Difficulty, Problem } from "@/generated/client"; import { cn, getDifficultyColorClass } from "@/lib/utils"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; +import { useTranslations } from "next-intl"; type ProblemTableItem = Pick; +const t = useTranslations('problemset'); + interface ProblemTableProps { data: ProblemTableItem[]; } @@ -117,14 +120,14 @@ const columns: ColumnDef[] = [ (table.getIsSomePageRowsSelected() && "indeterminate") } onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)} - aria-label="Select all" + aria-label= {t('select-all')} /> ), cell: ({ row }) => ( row.toggleSelected(!!value)} - aria-label="Select row" + aria-label= {t('select-row')} /> ), size: 28, @@ -140,12 +143,12 @@ const columns: ColumnDef[] = [ enableHiding: false, }, { - header: "Title", + header: t('title'), accessorKey: "title", cell: ({ row }) =>
{row.getValue("title")}
, }, { - header: "Difficulty", + header: t('difficulty'), accessorKey: "difficulty", cell: ({ row }) => { const difficulty = row.getValue("difficulty") as Difficulty; @@ -160,7 +163,7 @@ const columns: ColumnDef[] = [ }, { id: "actions", - header: () => Actions, + header: () => t('actions'), cell: () => , enableHiding: false, }, @@ -262,9 +265,9 @@ export function ProblemsetTable({ data }: ProblemTableProps) { onChange={(e) => table.getColumn("displayId")?.setFilterValue(e.target.value) } - placeholder="DisplayId or Title..." + placeholder={t('displayid-or-title')} type="text" - aria-label="Filter by displayId or title" + aria-label={t('filter-by-displayid-or-title')} />
- Are you absolutely sure? + {t('are-you-absolutely-sure')} - This action cannot be undone. This will permanently delete{" "} + {t('this-action-cannot-be-undone-this-will-permanently-delete')}{" "} {table.getSelectedRowModel().rows.length} selected{" "} {table.getSelectedRowModel().rows.length === 1 ? "row" @@ -399,9 +402,9 @@ export function ProblemsetTable({ data }: ProblemTableProps) { - Cancel + {t('cancel')} - Delete + {t('delete')} @@ -414,7 +417,7 @@ export function ProblemsetTable({ data }: ProblemTableProps) { size={16} aria-hidden="true" /> - Add Problem + {t('add-problem')} @@ -439,7 +442,7 @@ export function ProblemsetTable({ data }: ProblemTableProps) { onKeyDown={(e) => { if ( header.column.getCanSort() && - (e.key === "Enter" || e.key === " ") + (e.key === t('enter') || e.key === " ") ) { e.preventDefault(); header.column.getToggleSortingHandler()?.(e); @@ -499,7 +502,7 @@ export function ProblemsetTable({ data }: ProblemTableProps) { ) : ( - No results. + {t('problemset.no-results')} )} @@ -508,7 +511,7 @@ export function ProblemsetTable({ data }: ProblemTableProps) {
- +