Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion excalidraw-app/components/MyCreationsTab.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from "react";

import { t } from "@excalidraw/excalidraw/i18n";

import clsx from "clsx";

import { FilledButton } from "@excalidraw/excalidraw/components/FilledButton";
Expand Down Expand Up @@ -82,7 +84,7 @@ export const MyCreationsTab: React.FC<MyCreationsTabProps> = ({
/>
) : (
<div className="my-creations-tab__card-thumbnail--placeholder">
空空如也
{t("myCreations.noThumbnail")}
</div>
)}
<div className="my-creations-tab__card-info">
Expand Down
10 changes: 6 additions & 4 deletions excalidraw-app/hooks/useCanvasManagement.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useState, useCallback, useEffect } from "react";

import { t } from "@excalidraw/excalidraw/i18n";

import { CaptureUpdateAction } from "@excalidraw/element";

import type { ExcalidrawImperativeAPI } from "@excalidraw/excalidraw/types";
Expand Down Expand Up @@ -98,7 +100,7 @@ export const useCanvasManagement = ({
await refreshCanvases();
} catch (error: any) {
if (error instanceof AuthError) {
setErrorMessage("您需要登录才能删除此画布。");
setErrorMessage(t("canvasManagement.loginToDelete"));
} else {
setErrorMessage("Could not delete the canvas.");
}
Expand Down Expand Up @@ -137,7 +139,7 @@ export const useCanvasManagement = ({
setCurrentCanvasId(createdCanvas.id);
} catch (error: any) {
if (error instanceof AuthError) {
setErrorMessage("您需要登录才能创建新画布。");
setErrorMessage(t("canvasManagement.loginToCreate"));
} else {
setErrorMessage("Could not create new canvas.");
}
Expand All @@ -162,7 +164,7 @@ export const useCanvasManagement = ({
}
} catch (error: any) {
if (error instanceof AuthError) {
setErrorMessage("您需要登录才能重命名此画布。");
setErrorMessage(t("canvasManagement.loginToRename"));
} else {
setErrorMessage("Could not rename the canvas.");
}
Expand Down Expand Up @@ -200,7 +202,7 @@ export const useCanvasManagement = ({
setCurrentCanvasId(createdCanvas.id);
} catch (error: any) {
if (error instanceof AuthError) {
setErrorMessage("您需要登录才能另存为新画布。");
setErrorMessage(t("canvasManagement.loginToSaveAs"));
} else {
setErrorMessage("Could not save as new canvas.");
}
Expand Down
12 changes: 7 additions & 5 deletions excalidraw-app/utils/time.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
import { t } from "@excalidraw/excalidraw/i18n";

export const timeAgo = (date: string | number | Date): string => {
const now = new Date();
const past = new Date(date);
const diffInSeconds = Math.floor((now.getTime() - past.getTime()) / 1000);

if (diffInSeconds < 10) {
return "刚刚";
return t("timeAgo.justNow");
}
if (diffInSeconds < 60) {
return `${diffInSeconds} 秒前`;
return t("timeAgo.secondsAgo", { count: diffInSeconds });
}

const diffInMinutes = Math.floor(diffInSeconds / 60);
if (diffInMinutes < 60) {
return `${diffInMinutes} 分钟前`;
return t("timeAgo.minutesAgo", { count: diffInMinutes });
}

const diffInHours = Math.floor(diffInMinutes / 60);
if (diffInHours < 24) {
return `${diffInHours} 小时前`;
return t("timeAgo.hoursAgo", { count: diffInHours });
}

const diffInDays = Math.floor(diffInHours / 24);
if (diffInDays < 7) {
return `${diffInDays} 天前`;
return t("timeAgo.daysAgo", { count: diffInDays });
}

return new Date(date).toLocaleDateString();
Expand Down
16 changes: 16 additions & 0 deletions packages/excalidraw/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -653,5 +653,21 @@
},
"itemNotAvailable": "Command is not available...",
"shortcutHint": "For Command palette, use {{shortcut}}"
},
"myCreations": {
"noThumbnail": "No preview"
},
"timeAgo": {
"justNow": "just now",
"secondsAgo": "{{count}}s ago",
"minutesAgo": "{{count}}m ago",
"hoursAgo": "{{count}}h ago",
"daysAgo": "{{count}}d ago"
},
"canvasManagement": {
"loginToDelete": "You need to log in to delete this canvas.",
"loginToCreate": "You need to log in to create a new canvas.",
"loginToRename": "You need to log in to rename this canvas.",
"loginToSaveAs": "You need to log in to save as a new canvas."
}
}
16 changes: 16 additions & 0 deletions packages/excalidraw/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -533,5 +533,21 @@
"description": "目前仅支持<flowchartLink>流程图</flowchartLink>、<sequenceLink>序列图</sequenceLink>和<classLink>类图</classLink>。其他类型在 Excalidraw 中将以图像呈现。",
"syntax": "Mermaid 语法",
"preview": "预览"
},
"myCreations": {
"noThumbnail": "空空如也"
},
"timeAgo": {
"justNow": "刚刚",
"secondsAgo": "{{count}} 秒前",
"minutesAgo": "{{count}} 分钟前",
"hoursAgo": "{{count}} 小时前",
"daysAgo": "{{count}} 天前"
},
"canvasManagement": {
"loginToDelete": "您需要登录才能删除此画布。",
"loginToCreate": "您需要登录才能创建新画布。",
"loginToRename": "您需要登录才能重命名此画布。",
"loginToSaveAs": "您需要登录才能另存为新画布。"
}
}