refactor: support i18n

This commit is contained in:
mlogclub
2026-05-25 12:06:15 +08:00
parent 309ac1fe9e
commit 988f55c80d
179 changed files with 10968 additions and 3763 deletions
+7 -5
View File
@@ -10,6 +10,7 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
import { useI18n } from "@/i18n/provider"
type ListPaginationProps = {
page: number
@@ -30,6 +31,7 @@ export function ListPagination({
onPageChange,
onLimitChange,
}: ListPaginationProps) {
const t = useI18n()
const totalPages = Math.max(1, Math.ceil(total / limit))
const canGoPreviousPage = page > 1
const canGoNextPage = page < totalPages
@@ -49,9 +51,9 @@ export function ListPagination({
<div className="flex flex-col gap-3 text-sm text-muted-foreground sm:flex-row sm:items-center sm:justify-between">
<div className="flex items-center gap-3">
<span>
{page} / {totalPages}
{t("pagination.pageSummary", { page, totalPages })}
</span>
<span> {total} </span>
<span>{t("pagination.total", { total })}</span>
</div>
<div className="flex flex-wrap items-center gap-2">
<Select value={String(limit)} onValueChange={handleLimitChange}>
@@ -61,7 +63,7 @@ export function ListPagination({
<SelectContent>
{pageSizeOptions.map((pageSize) => (
<SelectItem key={pageSize} value={String(pageSize)}>
{pageSize}
{t("pagination.pageSize", { pageSize })}
</SelectItem>
))}
</SelectContent>
@@ -72,14 +74,14 @@ export function ListPagination({
disabled={loading || !canGoPreviousPage}
>
<ChevronLeftIcon />
{t("pagination.previous")}
</Button>
<Button
variant="outline"
onClick={() => onPageChange(page + 1)}
disabled={loading || !canGoNextPage}
>
{t("pagination.next")}
<ChevronRightIcon />
</Button>
</div>