feat: support i18n

This commit is contained in:
lleohao
2024-08-30 10:05:03 +08:00
parent 8af2d4e8cf
commit cd1a848b45
74 changed files with 12842 additions and 6775 deletions

View File

@ -13,11 +13,14 @@ import { formattedDate } from "@/lib/time.ts";
import { useRecentChangesQuery } from "@/features/page/queries/page-query.ts";
import { IconFileDescription } from "@tabler/icons-react";
import { getSpaceUrl } from "@/lib/config.ts";
import { useTranslation } from "react-i18next";
interface Props {
spaceId?: string;
}
export default function RecentChanges({ spaceId }: Props) {
const { t } = useTranslation("translation", { keyPrefix: "common" });
const { data: pages, isLoading, isError } = useRecentChangesQuery(spaceId);
if (isLoading) {
@ -25,7 +28,7 @@ export default function RecentChanges({ spaceId }: Props) {
}
if (isError) {
return <Text>Failed to fetch recent pages</Text>;
return <Text>{t("Failed to fetch recent pages")}</Text>;
}
return pages && pages.items.length > 0 ? (
@ -43,7 +46,7 @@ export default function RecentChanges({ spaceId }: Props) {
{page.icon || <IconFileDescription size={18} />}
<Text fw={500} size="md" lineClamp={1}>
{page.title || "Untitled"}
{page.title || t("Untitled")}
</Text>
</Group>
</UnstyledButton>
@ -73,7 +76,7 @@ export default function RecentChanges({ spaceId }: Props) {
</ScrollArea>
) : (
<Text size="md" ta="center">
No pages yet
{t("No pages yet")}
</Text>
);
}