From f3b23da931b5c2a721b49098804758a3525d0a6d Mon Sep 17 00:00:00 2001 From: Gucheng Wang Date: Tue, 28 Dec 2021 10:24:07 +0800 Subject: [PATCH] Improve translation. --- i18n/util.go | 1 + web/src/admin/AdminTopic.js | 360 ++++++----------------------------- web/src/locales/zh/data.json | 42 ++-- 3 files changed, 77 insertions(+), 326 deletions(-) diff --git a/i18n/util.go b/i18n/util.go index 52183daf..ab462837 100644 --- a/i18n/util.go +++ b/i18n/util.go @@ -37,6 +37,7 @@ func readI18nFile(language string) *I18nData { func writeI18nFile(language string, data *I18nData) { s := util.StructToJsonFormatted(data) + s = s + "\n" println(s) util.WriteStringToPath(s, getI18nFilePath(language)) diff --git a/web/src/admin/AdminTopic.js b/web/src/admin/AdminTopic.js index 13b895f0..36db27d7 100644 --- a/web/src/admin/AdminTopic.js +++ b/web/src/admin/AdminTopic.js @@ -110,20 +110,7 @@ class AdminTopic extends React.Component { } //un, ti, cn, sdt, cs, lrs, us, rcs, hs, fcs - TopicBackend.getTopicsAdmin( - this.state.un, - this.state.ti, - this.state.cn, - this.state.sdt, - this.state.cs, - this.state.lrs, - this.state.us, - this.state.rcs, - this.state.hs, - this.state.fcs, - this.state.limit, - this.state.page - ).then((res) => { + TopicBackend.getTopicsAdmin(this.state.un, this.state.ti, this.state.cn, this.state.sdt, this.state.cs, this.state.lrs, this.state.us, this.state.rcs, this.state.hs, this.state.fcs, this.state.limit, this.state.page).then((res) => { this.setState({ topics: res?.data, topicsNum: res?.data2, @@ -165,20 +152,7 @@ class AdminTopic extends React.Component { } getSearchResult() { - TopicBackend.getTopicsAdmin( - this.state.un, - this.state.ti, - this.state.cn, - this.state.sdt, - this.state.cs, - this.state.lrs, - this.state.us, - this.state.rcs, - this.state.hs, - this.state.fcs, - this.state.limit, - 1 - ).then((res) => { + TopicBackend.getTopicsAdmin(this.state.un, this.state.ti, this.state.cn, this.state.sdt, this.state.cs, this.state.lrs, this.state.us, this.state.rcs, this.state.hs, this.state.fcs, this.state.limit, 1).then((res) => { if (res.status === "ok") { window.history.pushState({}, 0, `/admin/topic`); this.setState({ @@ -208,14 +182,7 @@ class AdminTopic extends React.Component { return; } - return ( - - ); + return ; } clearMessage() { @@ -251,175 +218,62 @@ class AdminTopic extends React.Component { case "sdt": return ( - this.setState({ sdt: 1 })} - checked={this.state.sdt === 1} - name="sdt" - /> - {i18next.t("admin:Show")}{" "} - this.setState({ sdt: 0 })} - checked={this.state.sdt === 0} - name="sdt" - /> + this.setState({ sdt: 1 })} checked={this.state.sdt === 1} name="sdt" /> + {i18next.t("admin:Show")} this.setState({ sdt: 0 })} checked={this.state.sdt === 0} name="sdt" /> {i18next.t("admin:Hidden")} ); case "us": return ( - this.setState({ us: 1 })} - checked={this.state.us === 1} - name="us" - /> - {i18next.t("admin:Asc")}{" "} - this.setState({ us: 2 })} - checked={this.state.us === 2} - name="us" - /> - {i18next.t("admin:Desc")}{" "} - this.setState({ us: 0 })} - checked={this.state.us === 0} - name="us" - /> + this.setState({ us: 1 })} checked={this.state.us === 1} name="us" /> + {i18next.t("admin:Asc")} this.setState({ us: 2 })} checked={this.state.us === 2} name="us" /> + {i18next.t("admin:Desc")} this.setState({ us: 0 })} checked={this.state.us === 0} name="us" /> {i18next.t("admin:Ignore")} ); case "cs": return ( - this.setState({ cs: 1 })} - checked={this.state.cs === 1} - name="cs" - /> - {i18next.t("admin:Asc")}{" "} - this.setState({ cs: 2 })} - checked={this.state.cs === 2} - name="cs" - /> - {i18next.t("admin:Desc")}{" "} - this.setState({ cs: 0 })} - checked={this.state.cs === 0} - name="cs" - /> + this.setState({ cs: 1 })} checked={this.state.cs === 1} name="cs" /> + {i18next.t("admin:Asc")} this.setState({ cs: 2 })} checked={this.state.cs === 2} name="cs" /> + {i18next.t("admin:Desc")} this.setState({ cs: 0 })} checked={this.state.cs === 0} name="cs" /> {i18next.t("admin:Ignore")} ); case "lrs": return ( - this.setState({ lrs: 1 })} - checked={this.state.lrs === 1} - name="lrs" - /> - {i18next.t("admin:Asc")}{" "} - this.setState({ lrs: 2 })} - checked={this.state.lrs === 2} - name="lrs" - /> - {i18next.t("admin:Desc")}{" "} - this.setState({ lrs: 0 })} - checked={this.state.lrs === 0} - name="lrs" - /> + this.setState({ lrs: 1 })} checked={this.state.lrs === 1} name="lrs" /> + {i18next.t("admin:Asc")} this.setState({ lrs: 2 })} checked={this.state.lrs === 2} name="lrs" /> + {i18next.t("admin:Desc")} this.setState({ lrs: 0 })} checked={this.state.lrs === 0} name="lrs" /> {i18next.t("admin:Ignore")} ); case "rcs": return ( - this.setState({ rcs: 1 })} - checked={this.state.rcs === 1} - name="rcs" - /> - {i18next.t("admin:Asc")}{" "} - this.setState({ rcs: 2 })} - checked={this.state.rcs === 2} - name="rcs" - /> - {i18next.t("admin:Desc")}{" "} - this.setState({ rcs: 0 })} - checked={this.state.rcs === 0} - name="rcs" - /> + this.setState({ rcs: 1 })} checked={this.state.rcs === 1} name="rcs" /> + {i18next.t("admin:Asc")} this.setState({ rcs: 2 })} checked={this.state.rcs === 2} name="rcs" /> + {i18next.t("admin:Desc")} this.setState({ rcs: 0 })} checked={this.state.rcs === 0} name="rcs" /> {i18next.t("admin:Ignore")} ); case "hs": return ( - this.setState({ hs: 1 })} - checked={this.state.hs === 1} - name="hs" - /> - {i18next.t("admin:Asc")}{" "} - this.setState({ hs: 2 })} - checked={this.state.hs === 2} - name="hs" - /> - {i18next.t("admin:Desc")}{" "} - this.setState({ hs: 0 })} - checked={this.state.hs === 0} - name="hs" - /> + this.setState({ hs: 1 })} checked={this.state.hs === 1} name="hs" /> + {i18next.t("admin:Asc")} this.setState({ hs: 2 })} checked={this.state.hs === 2} name="hs" /> + {i18next.t("admin:Desc")} this.setState({ hs: 0 })} checked={this.state.hs === 0} name="hs" /> {i18next.t("admin:Ignore")} ); case "fcs": return ( - this.setState({ fcs: 1 })} - checked={this.state.fcs === 1} - name="fcs" - /> - {i18next.t("admin:Asc")}{" "} - this.setState({ fcs: 2 })} - checked={this.state.fcs === 2} - name="fcs" - /> - {i18next.t("admin:Desc")}{" "} - this.setState({ fcs: 0 })} - checked={this.state.fcs === 0} - name="fcs" - /> + this.setState({ fcs: 1 })} checked={this.state.fcs === 1} name="fcs" /> + {i18next.t("admin:Asc")} this.setState({ fcs: 2 })} checked={this.state.fcs === 2} name="fcs" /> + {i18next.t("admin:Desc")} this.setState({ fcs: 0 })} checked={this.state.fcs === 0} name="fcs" /> {i18next.t("admin:Ignore")} ); @@ -439,10 +293,7 @@ class AdminTopic extends React.Component { {i18next.t("topic:Author")} - this.setState({ un: event.target.value })} - /> + this.setState({ un: event.target.value })} /> @@ -450,10 +301,7 @@ class AdminTopic extends React.Component { {i18next.t("topic:Title")} - this.setState({ ti: event.target.value })} - /> + this.setState({ ti: event.target.value })} /> @@ -461,17 +309,12 @@ class AdminTopic extends React.Component { {i18next.t("topic:Content")} - this.setState({ cn: event.target.value })} - /> + this.setState({ cn: event.target.value })} /> - - {i18next.t("topic:Show deleted topics")} - + {i18next.t("topic:Show deleted topics")} {this.renderRadioButton("sdt")} @@ -527,12 +370,7 @@ class AdminTopic extends React.Component { - this.getSearchResult()} - /> + this.getSearchResult()} /> @@ -542,11 +380,7 @@ class AdminTopic extends React.Component { renderManagementList(item) { return ( - this.changeEvent(item.value)} - > + this.changeEvent(item.value)}> {i18next.t(`topic:${item.label}`)} ); @@ -556,16 +390,9 @@ class AdminTopic extends React.Component { return (
- {Setting.getForumName()}{" "} -  ›  - - {i18next.t("admin:Backstage management")} - {" "} -  ›  - - {i18next.t("topic:Topic management")} - {" "} -  ›  + {Setting.getForumName()}  ›  + {i18next.t("admin:Backstage management")}  ›  + {i18next.t("topic:Topic management")}  ›  {this.state.topic?.title}
@@ -600,23 +427,13 @@ class AdminTopic extends React.Component { case 2: return {i18next.t("topic:Deleted")}; case 3: - return ( - {i18next.t("topic:Node Topping")} - ); + return {i18next.t("topic:Node Topping")}; case 4: - return ( - {i18next.t("topic:Tab Topping")} - ); + return {i18next.t("topic:Tab Topping")}; case 5: - return ( - - {i18next.t("topic:Homepage Topping")} - - ); + return {i18next.t("topic:Homepage Topping")}; default: - return ( - {i18next.t("topic:Unknown status")} - ); + return {i18next.t("topic:Unknown status")}; } } @@ -630,15 +447,8 @@ class AdminTopic extends React.Component { - - {topic?.title.length > 30 - ? topic?.title.slice(0, 30) + "..." - : topic?.title} + + {topic?.title.length > 30 ? topic?.title.slice(0, 30) + "..." : topic?.title} @@ -646,18 +456,11 @@ class AdminTopic extends React.Component { {topic?.author} - - {i18next.t("admin:Manage")} - + {i18next.t("admin:Manage")} - {this.renderTopicStatus( - topic?.deleted, - topic?.homePageTopTime, - topic?.tabTopTime, - topic?.nodeTopTime - )} + {this.renderTopicStatus(topic?.deleted, topic?.homePageTopTime, topic?.tabTopTime, topic?.nodeTopTime)} @@ -677,13 +480,10 @@ class AdminTopic extends React.Component {
{Setting.getForumName()} -  › {" "} - {i18next.t("loading:Page is loading")} +  ›  {i18next.t("loading:Page is loading")}
- - {i18next.t("loading:Please wait patiently...")} - + {i18next.t("loading:Please wait patiently...")}
); @@ -694,9 +494,7 @@ class AdminTopic extends React.Component {
- {Setting.getForumName()}{" "} -  › {" "} - {i18next.t("error:Topic does not exist")} + {Setting.getForumName()}  ›  {i18next.t("error:Topic does not exist")}
404 Topic Not Found @@ -751,19 +549,12 @@ class AdminTopic extends React.Component { - + {topic?.nodeName}    {" "} - + {i18next.t("topic:Move topic")} @@ -781,15 +572,7 @@ class AdminTopic extends React.Component { {i18next.t("topic:Last reply user")} - - {topic.lastReplyUser === "" ? ( - i18next.t("topic: No reply yet") - ) : ( - - {topic?.lastReplyUser} - - )} - + {topic.lastReplyUser === "" ? i18next.t("reply:No reply yet") : {topic?.lastReplyUser}} {topic.lastReplyUser !== "" ? ( @@ -839,24 +622,13 @@ class AdminTopic extends React.Component { {i18next.t("topic:Status")} - - {this.renderTopicStatus( - topic?.deleted, - topic?.homePageTopTime, - topic?.tabTopTime, - topic?.nodeTopTime - )} - + {this.renderTopicStatus(topic?.deleted, topic?.homePageTopTime, topic?.tabTopTime, topic?.nodeTopTime)} - - {i18next.t( - "topic:Please change the basic information through the topic page" - )} - + {i18next.t("topic:Please change the basic information through the topic page")} @@ -879,12 +651,7 @@ class AdminTopic extends React.Component { {i18next.t("topic:Title")} - + {topic?.title} @@ -905,10 +672,7 @@ class AdminTopic extends React.Component { image: this.renderImage, link: this.renderLink, }} - source={Setting.getFormattedContent( - this.state.topic?.content, - true - )} + source={Setting.getFormattedContent(this.state.topic?.content, true)} escapeHtml={false} />
@@ -937,15 +701,11 @@ class AdminTopic extends React.Component { return (
- {Setting.getForumName()}{" "} -  ›  + {Setting.getForumName()}  ›  {i18next.t("admin:Backstage management")} -  › {" "} - {i18next.t("topic:Topic management")} +  ›  {i18next.t("topic:Topic management")}
- - {i18next.t("topic:Total Topics")}   - + {i18next.t("topic:Total Topics")}   {this.state.topicsNum}
@@ -965,15 +725,7 @@ class AdminTopic extends React.Component { backgroundColor: "#ffffff", }} > - - {i18next.t("admin:Condition search")} - - } - > - {this.renderSearchList()} - + {i18next.t("admin:Condition search")}}>{this.renderSearchList()}
{this.showPageColumn()} @@ -989,9 +741,7 @@ class AdminTopic extends React.Component { lineHeight: "100px", }} > - {this.state.topics === null - ? i18next.t("loading:Data is loading...") - : i18next.t("admin:No matching data")} + {this.state.topics === null ? i18next.t("loading:Data is loading...") : i18next.t("admin:No matching data")}
)}
diff --git a/web/src/locales/zh/data.json b/web/src/locales/zh/data.json index 24a9d86d..68ae7c62 100644 --- a/web/src/locales/zh/data.json +++ b/web/src/locales/zh/data.json @@ -45,11 +45,11 @@ "Created a": "创建了长度为", "Current account balance": "当前账户余额", "Description": "描述", - "Pin it to the top": "Pin it to the top", + "Pin it to the top": "置顶", "Received thanks": "收到谢意", "Recharge": "充值", "Reduce balance": "将你的余额减少", - "Reply in": "Reply in", + "Reply in": "回复于", "Rich ranking": "社区财富排行榜", "Send thanks": "发送谢意", "Thanks": "感谢", @@ -114,8 +114,8 @@ "Reply content cannot be empty": "回复内容不能为空", "Retry Sign Out": "重新登出", "Tab not found": "类别未找到", - "The node is currently in invisible state.": "该节点目前位于一个 invisible 位面", - "Topic does not exist": "Topic does not exist", + "The node is currently in invisible state.": "该节点目前位于一个隐藏位面中", + "Topic does not exist": "主题不存在", "Topic not found": "主题未找到", "Topic title cannot be empty": "主题标题不能为空" }, @@ -168,12 +168,12 @@ "Tools": "实用小工具" }, "frontConf": { - "Footer Logo URL": "底部logo图片超链接", - "Footer Logo image": "底部logo图片", + "Footer Logo URL": "底部Logo图片超链接", + "Footer Logo image": "底部Logo图片", "Footer subtitle": "底部建言", "Footer title": "底部描述", "Forum name": "论坛名字", - "Logo image": "logo图片", + "Logo image": "Logo图片", "Reset": "重置", "Right subtitle": "登录栏子标题", "Right title": "登录栏标题", @@ -192,14 +192,14 @@ "Sign In to Comment": "登录后评论", "Sign Out": "登出", "Sign Up": "注册", - "Swagger": "API文档", + "Swagger": "Swagger API文档", "Timeline": "时间轴", "false": "否", "true": "是" }, "loading": { - "Content loading": "Content loading", - "Data is loading...": "Data is loading...", + "Content loading": "内容正在加载", + "Data is loading...": "数据正在加载...", "File is loading": "文件正在加载", "Member profile is loading": "用户资料正在加载", "Node is loading": "节点正在加载", @@ -254,10 +254,10 @@ "Please select a node": "请选择一个节点", "Preview": "预览主题", "Publish": "发布主题", - "RichText": "RichText", + "RichText": "富文本", "Switch editor": "切换编辑器", "Topic Title": "主题标题", - "markdown": "MarkDown", + "markdown": "Markdown", "richtext": "富文本" }, "newNodeTopic": { @@ -269,7 +269,7 @@ "Add moderator": "新增版主", "Add moderator success": "添加版主成功", "Add new node": "新增节点", - "Adding image failed": "Adding image failed", + "Adding image failed": "添加图片失败", "All topics": "全部主题", "Background color": "背景颜色", "Background image": "背景图片", @@ -288,7 +288,7 @@ "Hot": "热度", "Ignore this node": "忽略这个节点", "Image": "图标", - "Is hidden": "Is hidden", + "Is hidden": "隐藏", "Mailing List": "邮件列表管理员邮箱", "Manage": "管理", "Manage moderators": "管理版主", @@ -298,7 +298,7 @@ "New node": "新增节点", "No mailing list yet": "未设置邮件列表", "No moderators": "暂无版主", - "No node yet": "No node yet", + "No node yet": "暂无节点", "Node ID": "节点 ID", "Node management": "节点管理", "Node name": "节点名称", @@ -352,7 +352,7 @@ "Manage": "管理", "New plane": "新建位面", "No node yet": "暂无节点", - "No plant yet": "No plant yet", + "No plant yet": "暂无位面", "Nodes": "节点", "Not set": "未设定", "Plane ID": "位面ID", @@ -376,7 +376,7 @@ "Picture link": "图片链接", "Poster management": "广告管理", "Save": "保存", - "Update frontconf information success": "Update frontconf information success", + "Update frontconf information success": "更新前端设置成功", "Update poster information success": "更新广告信息成功" }, "reply": { @@ -386,8 +386,8 @@ "Edit": "编辑", "No reply yet": "目前尚无回复", "Reply": "回复", - "Sign in": "Sign in", - "Sign up": "Sign up", + "Sign in": "登录", + "Sign up": "注册", "Undock": "取消回复框停靠", "ignore": "隐藏", "replies": "条回复", @@ -420,7 +420,7 @@ "Manage": "管理", "New tab": "新建类别", "No node exists in this tab": "此类别下不存在节点", - "No tab yet": "No tab yet", + "No tab yet": "暂无Tab", "Save": "保存", "Sorter": "类别排序", "Tab ID": "类别 ID", @@ -506,7 +506,7 @@ "Topic meta information": "主题元信息", "Total Topics": "主题总数", "Treatment of link handling type spam": "对于链接搬运类型 spam 的处理", - "Unknown status": "Unknown status", + "Unknown status": "未知状态", "Virtual currency system": "虚拟货币系统", "community": "社区的主题管理相关功能:", "days ago, the information in it may have changed.": "天前的主题,其中的信息可能已经有所发展或是发生改变。",