Skip to content

Commit

Permalink
Translate buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
longern committed Dec 26, 2023
1 parent 8131448 commit 7717d0c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/admin/Posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ function Posts({ type }: { type: "page" | "post" }) {

const handlePublish = useCallback((post: Post) => {
setAnchorEl(null);
setActivePost(null);
fetch(`/api/posts/${post.rowid}`, {
method: "PATCH",
headers: {
Expand All @@ -77,9 +76,8 @@ function Posts({ type }: { type: "page" | "post" }) {
}).then(() => setActiveTab(0));
}, []);

const handleUnpublish = useCallback((post: Post) => {
const handleDepublish = useCallback((post: Post) => {
setAnchorEl(null);
setActivePost(null);
fetch(`/api/posts/${post.rowid}`, {
method: "PATCH",
headers: {
Expand Down Expand Up @@ -178,10 +176,7 @@ function Posts({ type }: { type: "page" | "post" }) {
<Menu
open={Boolean(anchorEl)}
anchorEl={anchorEl}
onClose={() => {
setAnchorEl(null);
setActivePost(null);
}}
onClose={() => setAnchorEl(null)}
anchorOrigin={{
vertical: "bottom",
horizontal: "right",
Expand Down Expand Up @@ -210,11 +205,11 @@ function Posts({ type }: { type: "page" | "post" }) {
<ListItemText primary={t("Edit")}></ListItemText>
</MenuItem>
{activePost?.status === "publish" ? (
<MenuItem onClick={() => handleUnpublish(activePost)}>
<MenuItem onClick={() => handleDepublish(activePost)}>
<ListItemIcon>
<PublicOffIcon />
</ListItemIcon>
<ListItemText primary={t("Unpublish")}></ListItemText>
<ListItemText primary={t("Depublish")}></ListItemText>
</MenuItem>
) : (
<MenuItem onClick={() => handlePublish(activePost)}>
Expand All @@ -225,10 +220,13 @@ function Posts({ type }: { type: "page" | "post" }) {
</MenuItem>
)}
<MenuItem onClick={() => handleDelete(activePost)}>
<ListItemIcon color="error">
<DeleteIcon />
<ListItemIcon>
<DeleteIcon color="error" />
</ListItemIcon>
<ListItemText primary={t("Delete")} color="error"></ListItemText>
<ListItemText
primary={t("Delete")}
primaryTypographyProps={{ color: "error" }}
></ListItemText>
</MenuItem>
</Menu>
</Container>
Expand Down
12 changes: 12 additions & 0 deletions src/locales.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Blog Name": "Blog Name",
"Blog Description": "Blog Description",
"Delete": "Delete",
"Depublish": "Depublish",
"Drafts": "Drafts",
"Edit": "Edit",
"Home": "Home",
Expand All @@ -16,13 +17,15 @@
"Pages": "Pages",
"Password": "Password",
"Posts": "Posts",
"Publish": "Publish",
"Published": "Published",
"Retry": "Retry",
"Save": "Save",
"Settings": "Settings",
"Title": "Title",
"(Untitled)": "(Untitled)",
"Username": "Username",
"View": "View",
"View blog": "View blog",
"Write something...": "Write something..."
}
Expand All @@ -33,6 +36,7 @@
"Blog Name": "블로그 이름",
"Blog Description": "블로그 설명",
"Delete": "삭제",
"Depublish": "발행 취소",
"Drafts": "임시",
"Edit": "편집",
"Home": "",
Expand All @@ -44,13 +48,15 @@
"Pages": "페이지",
"Password": "비밀번호",
"Posts": "",
"Publish": "발행",
"Published": "발행됨",
"Retry": "재시도",
"Save": "저장",
"Settings": "설정",
"Title": "제목",
"(Untitled)": "(제목 없음)",
"Username": "사용자 이름",
"View": "보기",
"View blog": "블로그 보기",
"Write something...": "글을 써보세요..."
}
Expand All @@ -61,6 +67,7 @@
"Blog Name": "ブログ名",
"Blog Description": "ブログの説明",
"Delete": "削除",
"Depublish": "下書きに戻す",
"Drafts": "下書き",
"Edit": "編集",
"Home": "ホーム",
Expand All @@ -72,13 +79,15 @@
"Pages": "ページ",
"Password": "パスワード",
"Posts": "投稿",
"Publish": "公開",
"Published": "公開",
"Retry": "リトライ",
"Save": "保存",
"Settings": "設定",
"Title": "タイトル",
"(Untitled)": "(無題)",
"Username": "ユーザー名",
"View": "表示",
"View blog": "ブログを見る",
"Write something...": "何か書いてみましょう..."
}
Expand All @@ -89,6 +98,7 @@
"Blog Name": "博客名称",
"Blog Description": "博客描述",
"Delete": "删除",
"Depublish": "取消发布",
"Drafts": "草稿",
"Edit": "编辑",
"Home": "主页",
Expand All @@ -100,13 +110,15 @@
"Pages": "页面",
"Password": "密码",
"Posts": "文章",
"Publish": "发布",
"Published": "已发布",
"Retry": "重试",
"Save": "保存",
"Settings": "设置",
"Title": "标题",
"(Untitled)": "(无标题)",
"Username": "用户名",
"View": "查看",
"View blog": "查看博客",
"Write something...": "写点什么..."
}
Expand Down

0 comments on commit 7717d0c

Please sign in to comment.