From a5682f1308ed702e96ec40a6a8429e391a07621c Mon Sep 17 00:00:00 2001 From: shiqstone Date: Sun, 11 Apr 2021 01:20:47 +0800 Subject: [PATCH] refactor and update i18n, to be continue --- conf/lang/en-us.ini | 149 ++++++++++++++ conf/lang/zh-cn.ini | 149 ++++++++++++++ controllers/BookController.go | 33 ++-- controllers/DocumentController.go | 225 +++++++++++----------- views/book/team.tpl | 2 +- views/document/compare.tpl | 16 +- views/document/default_read.tpl | 105 +++------- views/document/document_password.tpl | 10 +- views/document/history.tpl | 26 +-- views/document/markdown_edit_template.tpl | 184 +++++++++--------- views/document/new_html_edit_template.tpl | 105 +++++----- views/errors/403.tpl | 4 +- views/errors/404.tpl | 4 +- views/errors/error.tpl | 4 +- 14 files changed, 635 insertions(+), 381 deletions(-) diff --git a/conf/lang/en-us.ini b/conf/lang/en-us.ini index 07baa819..0e474d85 100644 --- a/conf/lang/en-us.ini +++ b/conf/lang/en-us.ini @@ -39,10 +39,15 @@ operate = Operate confirm = Confirm [message] +tips = Tips +page_not_existed = The page does not exist +no_permission = No enough permissions keyword_placeholder = input keyword please... wrong_account_password = Incorrect username or password +wrong_password = Wrong password click_to_change = Click to change one logging_in = logging in... +need_relogin = Relogin please. return_account_login = Return account password login no_account_yet = No account yet? has_account = Already have an account? @@ -78,7 +83,9 @@ dingtalk_auto_login_not_enable = DingTalk automatic login function is not enable failed_auto_login = Automatic login failed no_project = No Project item_not_exist = Item does not exist or has been deleted +item_not_exist_or_no_permit = Item does not exist or has insufficient permissions doc_not_exist = Document does not exist or has been deleted +doc_not_exist_or_no_permit = Document does not exist or has insufficient permissions unknown_exception = Unknown Exception no_data = No Data project_must_belong_space = Project must belong to a project space, and the administrator can manage it @@ -95,6 +102,8 @@ warning_delete_project = Remove items will not be retrieved. project_space_empty = Please select project space project_title_empty = Project title cannot be empty project_id_empty = Project ID cannot be empty +project_id_existed = Project ID already in use +project_id_error = Project ID error project_id_length = Project ID must be less than 50 characters import_file_empty = Please select the file to upload file_type_placeholder = Please select a Zip file @@ -105,6 +114,7 @@ project_id_desc = The project ID is used to mark the uniqueness of the item and history_record_amount_desc = When document history enabled, this value limits the number of history saved per document corp_id_desc = The footer that appears when the document PDF document is exported project_desc_desc = The description information is no more than 500 characters, supports markdown syntax +project_desc_tips = The description information is no more than 500 characters access_pass_desc = The password that needs to be provided to access the project without permit auto_publish_desc = Enable for each save is automatically published to the latest version enable_export_desc = Configure the exporter before you start the export, also enable the export function in the profile @@ -121,7 +131,32 @@ receive_account_empty = The recipient account cannot be empty cannot_preview = Cannot preview upload_failed = Upload failed upload_file_size_limit = The file must be less than 2MB +upload_file_empty = Upload file is empty +uploda_file_type_error = upload file type is wrong choose_pic_file = Please select a picture +no_doc_in_cur_proj = No documents for the current project +build_doc_tree_error = There was an error building the project document tree +param_error = Parameter error +doc_name_empty = Document name cannot empty +parent_id_not_existed = Parent ID not existed +doc_not_belong_project = The document does not belong to the specified project` +attachment_not_exist = Attachment does not exist +read_file_error = Load file error +confirm_override_doc = The document has been modified, are you sure to override it? +doc_auto_published = The document was automatically published +export_func_disable = The export function is disable +cur_project_export_func_disable = The export function is disable for current Project +cur_project_not_support_md = The Markdown editor is not supported for the current project +export_failed = The export failed, check the system logs +file_converting = The document is being converted in the background, please download it later +unsupport_file_type = Unsupport file type +no_exportable_file = The project has no exportable file +gen_qrcode_failed = Generate QrCode failed +search_result_error = Search error +get_doc_his_failed = Fail to get document history +project_space_not_exist = Project space does not exist +search_placeholder = input keyword please +no_search_result = No search results! [blog] author = author @@ -188,6 +223,120 @@ choose = Choose upload = Upload recipient_account = Recipient +[doc] +modify_doc = Modify Document +comparison = Comparison +save_merge = Save Merge +prev_diff = Previous difference +next_diff = Next difference +merge_to_left = Merge to left +merge_to_right = Merge to right +exchange_left_right = Exchange left and right +print = Print +download = Download +share = Share +share_project = Share project +share_url = Project URL +contents = Contents +search = Search +expand = Unfold +fold = Fold +close = Close +doc_tool_copyright = Document is Published by MinDoc +edit_doc = Edit Document +backward = backward +save = save +save_as_tpl = save as template +undo = undo +redo = redo +bold = bold +italic = italic +strikethrough = strikethrough +h1 = head 1 +h2 = head 2 +h3 = head 3 +h4 = head 4 +h5 = head 5 +h6 = head 6 +unorder_list = disorder list +order_list = order list +hline = horizontal line +link = link +ref_link = reference link +add_pic = add picture +code = code +code_block = code block +table = add table +quote = quote +gfm_task = GFM task +attachment = attachment +json_to_table = Json converted to table +template = template +close_preview = disable preview +modify_history = modify history +sidebar = sidebar +help = help +publish = publish +document = document +create_doc = create document +attachments = attachments +doc_name = Document name +doc_name_tips = Right-click on the document name of the directory to delete and modify the document name and add subordinate documents +doc_id = Document ID +doc_id_tips = The document ID can only contain lowercase letters, numbers, and "-" and "_" symbols, and can only start with a lowercase letter +expand_desc = (Expand nodes when reading) +fold_desc = (Fold nodes when reading) +empty_contents = Empty contents +empty_contents_desc = Click to expand the subordinate nodes +upload_attachment = Upload attachment +doc_history = Document history +choose_template_type = Choose template type please +normal_tpl = Normal +api_tpl = API +data_dict = Data Dictionary +custom_tpl = Custom +tpl_default_type = Default type +tpl_plain_text = Plain Text +for_api_doc = Used for API Document +code_highlight = support code highlighting +for_data_dict = Used for data dictionary +form_support = Form Support +any_type_doc = Support any type of document +as_global_tpl = Can be set as a global template +tpl_name = Template name +tpl_type = Template type +creator = Creator +create_time = Create time +operation = Operation +global_tpl = Global +global_tpl_desc = (Any Project is available) +project_tpl = Project +project_tpl_desc = (Only the current Project is available) +insert = insert +uploading = Uploading +his_ver = Historic version +update_time = Update time +updater = Updater +version = Version +delete = Delete +recover = Recover +merge = Merge +comparison_title = Document comparison [the left is the historical document, the right is the current document, please merge the documents to the right] +font_size = font size +underscore = underscore +right_intent = right intent +left_intent = left intent +subscript = subscript +superscript = superscript +clean_format = clear format +add_video = add video +formula = formula +font_color = font color +bg_color = background color +input_pwd = input password please +read_pwd = read password +commit = commit + [page] first = first last = last diff --git a/conf/lang/zh-cn.ini b/conf/lang/zh-cn.ini index 446bf2df..8b924f30 100644 --- a/conf/lang/zh-cn.ini +++ b/conf/lang/zh-cn.ini @@ -39,10 +39,15 @@ operate = 操作 confirm = 确定 [message] +tips = 友情提示 +page_not_existed = 页面不存在 +no_permission = 权限不足 keyword_placeholder = 请输入关键词... wrong_account_password = 账号或密码错误 +wrong_password = 密码错误 click_to_change = 点击换一张 logging_in = 正在登录... +need_relogin = 请重新登录。 return_account_login = 返回账号密码登录 no_account_yet = 还没有账号? has_account = 已有账号? @@ -78,7 +83,9 @@ dingtalk_auto_login_not_enable = 未开启钉钉自动登录功能 failed_auto_login = 自动登录失败 no_project = 暂无项目 item_not_exist = 项目不存在或已删除 +item_not_exist_or_no_permit = 项目不存在或权限不足 doc_not_exist = 文档不存在或已删除 +doc_not_exist_or_no_permit = 文档不存在或权限不足 unknown_exception = 未知异常 no_data = 暂无数据 project_must_belong_space = 每个项目必须归属一个项目空间,超级管理员可在后台管理和维护 @@ -95,6 +102,8 @@ warning_delete_project = 删除项目后将无法找回。 project_space_empty = 请选择项目空间 project_title_empty = 项目标题不能为空 project_id_empty = 项目标识不能为空 +project_id_existed = 文档标识已被使用 +project_id_error = 项目标识有误 project_id_length = 项目标识必须小于50字符 import_file_empty = 请选择需要上传的文件 file_type_placeholder = 请选择Zip文件 @@ -105,6 +114,7 @@ project_id_desc = 项目标识用来标记项目的唯一性,不可修改。 history_record_amount_desc = 当开启文档历史时,该值会限制每个文档保存的历史数量 corp_id_desc = 导出文档PDF文档时显示的页脚 project_desc_desc = 描述信息不超过500个字符,支持Markdown语法 +project_desc_tips = 项目描述不能大于500字 access_pass_desc = 没有访问权限访问项目时需要提供的密码 auto_publish_desc = 开启后,每次保存会自动发布到最新版本 enable_export_desc = 开启导出前请先配置导出程序,并在配置文件中同时开启导出功能 @@ -121,7 +131,32 @@ receive_account_empty = 接受者账号不能为空 cannot_preview = 不能预览 upload_failed = 上传失败 upload_file_size_limit = 文件必须小于2MB +upload_file_empty = 上传文件为空 +uploda_file_type_error = 文件类型有误 choose_pic_file = 请选择图片 +no_doc_in_cur_proj = 当前项目没有文档 +build_doc_tree_error = 生成项目文档树时出错 +param_error = 参数错误 +doc_name_empty = 文档名称不能为空 +parent_id_not_existed = 父分类不存在 +doc_not_belong_project = 文档不属于指定的项目 +attachment_not_exist = 附件不存在或已删除 +read_file_error = 读取文档错误 +confirm_override_doc = 文档已被修改确定要覆盖吗? +doc_auto_published = 文档自动发布成功 +export_func_disable = 系统没有开启导出功能 +cur_project_export_func_disable = 当前项目没有开启导出功能 +cur_project_not_support_md = 当前项目不支持Markdown编辑器 +export_failed = 导出失败,请查看系统日志 +file_converting = 文档正在后台转换,请稍后再下载 +unsupport_file_type = 不支持的文件格式 +no_exportable_file = 项目没有导出文件 +gen_qrcode_failed = 生成二维码失败 +search_result_error = 搜索结果错误 +get_doc_his_failed = 获取历史失败 +project_space_not_exist = 项目空间不存在 +search_placeholder = 请输入搜索关键字 +no_search_result = 暂无相关搜索结果! [blog] author = 作者 @@ -188,6 +223,120 @@ choose = 选择 upload = 上传 recipient_account = 接收者账号 +[doc] +modify_doc = 修改文档 +comparison = 文档比较 +save_merge = 保存合并 +prev_diff = 上一处差异 +next_diff = 下一处差异 +merge_to_left = 合并到左侧 +merge_to_right = 合并到右侧 +exchange_left_right = 左右切换 +print = 打印 +download = 下载 +share = 分享 +share_project = 项目分享 +share_url = 项目地址 +contents = 目录 +search = 搜索 +expand = 展开 +fold = 收起 +close = 关闭 +doc_tool_copyright = 本文档使用 MinDoc 发布 +edit_doc = 编辑文档 +backward = 返回 +save = 保存 +save_as_tpl = 保存为模板 +undo = 撤销 +redo = 重做 +bold = 粗体 +italic = 斜体 +strikethrough = 删除线 +h1 = 标题一 +h2 = 标题二 +h3 = 标题三 +h4 = 标题四 +h5 = 标题五 +h6 = 标题六 +unorder_list = 无序列表 +order_list = 有序列表 +hline = Horizontal line +link = 链接 +ref_link = 引用链接 +add_pic = 添加图片 +code = 行内代码 +code_block = 代码块 +table = 添加表格 +quote = 引用 +gfm_task = GFM 任务列表 +attachment = 附件 +json_to_table = Json转换为表格 +template = 模板 +close_preview = 关闭实时预览 +modify_history = 修改历史 +sidebar = 边栏 +help = 使用帮助 +publish = 发布 +document = 文档 +create_doc = 创建文档 +attachments = 个附件 +doc_name = 文档名称 +doc_name_tips = 在目录的文档名上右键可以删除和修改文档名称以及添加下级文档 +doc_id = 文档标识 +doc_id_tips = 文档标识只能包含小写字母、数字,以及“-”和“_”符号,并且只能小写字母开头 +expand_desc = (在阅读时会自动展开节点) +fold_desc = (在阅读时会关闭节点) +empty_contents = 空目录 +empty_contents_desc = (单击时会展开下级节点) +upload_attachment = 上传附件 +doc_history = 文档历史记录 +choose_template_type = 请选择模板类型 +normal_tpl = 普通文档 +api_tpl = API文档 +data_dict = 数据字典 +custom_tpl = 自定义模板 +tpl_default_type = 默认类型 +tpl_plain_text = 简单的文本文档 +for_api_doc = 用于API文档速写 +code_highlight = 支持代码高亮 +for_data_dict = 用于数据字典显示 +form_support = 表格支持 +any_type_doc = 支持任意类型文档 +as_global_tpl = 可以设置为全局模板 +tpl_name = 模板名称 +tpl_type = 模板类型 +creator = 创建人 +create_time = 创建时间 +operation = 操作 +global_tpl = 全局 +global_tpl_desc = (任何项目都可用) +project_tpl = 项目 +project_tpl_desc = (只有当前项目可用) +insert = 插入 +uploading = 正在上传 +his_ver = 历史版本 +update_time = 修改时间 +updater = 修改人 +version = 版本 +delete = 删除 +recover = 恢复 +merge = 合并 +comparison_title = 文档比较【左侧为历史文档,右侧为当前文档,请将文档合并到右侧】 +font_size = 字号 +underscore = 下划线 +right_intent = 右缩进 +left_intent = 左缩进 +subscript = 下标 +superscript = 上标 +clean_format = 清空格式 +add_video = 添加视频 +formula = 公式 +font_color = 字体颜色 +bg_color = 背景颜色 +input_pwd = 请输入密码 +read_pwd = 浏览密码 +commit = 提交 + [page] first = 首页 last = 末页 diff --git a/controllers/BookController.go b/controllers/BookController.go index 9920037f..f4fbdfd6 100644 --- a/controllers/BookController.go +++ b/controllers/BookController.go @@ -12,6 +12,7 @@ import ( "strings" "time" + "github.com/beego/i18n" "github.com/mindoc-org/mindoc/utils/sqltil" "net/http" @@ -153,14 +154,14 @@ func (c *BookController) SaveBook() { itemId, _ := c.GetInt("itemId") if strings.Count(description, "") > 500 { - c.JsonResult(6004, "项目描述不能大于500字") + c.JsonResult(6004, i18n.Tr(c.Lang, "message.project_desc_tips")) } if commentStatus != "open" && commentStatus != "closed" && commentStatus != "group_only" && commentStatus != "registered_only" { commentStatus = "closed" } if !models.NewItemsets().Exist(itemId) { - c.JsonResult(6006, "项目空间不存在") + c.JsonResult(6006, i18n.Tr(c.Lang, "message.project_space_not_exist")) } if editor != "markdown" && editor != "html" { editor = "markdown" @@ -449,25 +450,25 @@ func (c *BookController) Create() { itemId, _ := c.GetInt("itemId") if bookName == "" { - c.JsonResult(6001, "项目名称不能为空") + c.JsonResult(6001, i18n.Tr(c.Lang, "message.project_name_empty")) } if identify == "" { - c.JsonResult(6002, "项目标识不能为空") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.project_id_empty")) } if ok, err := regexp.MatchString(`^[a-z]+[a-zA-Z0-9_\-]*$`, identify); !ok || err != nil { - c.JsonResult(6003, "项目标识只能包含小写字母、数字,以及“-”和“_”符号,并且只能小写字母开头") + c.JsonResult(6003, i18n.Tr(c.Lang, "message.project_id_tips")) } if strings.Count(identify, "") > 50 { - c.JsonResult(6004, "文档标识不能超过50字") + c.JsonResult(6004, i18n.Tr(c.Lang, "message.project_id_length")) } if strings.Count(description, "") > 500 { - c.JsonResult(6004, "项目描述不能大于500字") + c.JsonResult(6004, i18n.Tr(c.Lang, "message.project_desc_tips")) } if privatelyOwned != 0 && privatelyOwned != 1 { privatelyOwned = 1 } if !models.NewItemsets().Exist(itemId) { - c.JsonResult(6005, "项目空间不存在") + c.JsonResult(6005, i18n.Tr(c.Lang, "message.project_space_not_exist")) } if commentStatus != "open" && commentStatus != "closed" && commentStatus != "group_only" && commentStatus != "registered_only" { commentStatus = "closed" @@ -504,7 +505,7 @@ func (c *BookController) Create() { } if books, _ := book.FindByField("identify", identify, "book_id"); len(books) > 0 { - c.JsonResult(6006, "项目标识已存在") + c.JsonResult(6006, i18n.Tr(c.Lang, "message.project_id_existed")) } book.BookName = bookName @@ -528,7 +529,7 @@ func (c *BookController) Create() { if err := book.Insert(); err != nil { logs.Error("Insert => ", err) - c.JsonResult(6005, "保存项目失败") + c.JsonResult(6005, i18n.Tr(c.Lang, "message.failed")) } bookResult, err := models.NewBookResult().FindByIdentify(book.Identify, c.Member.MemberId) @@ -585,22 +586,22 @@ func (c *BookController) Import() { itemId, _ := c.GetInt("itemId") if bookName == "" { - c.JsonResult(6001, "项目名称不能为空") + c.JsonResult(6001, i18n.Tr(c.Lang, "message.project_name_empty")) } if len([]rune(bookName)) > 500 { c.JsonResult(6002, "项目名称不能大于500字") } if identify == "" { - c.JsonResult(6002, "项目标识不能为空") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.project_id_empty")) } if ok, err := regexp.MatchString(`^[a-z]+[a-zA-Z0-9_\-]*$`, identify); !ok || err != nil { - c.JsonResult(6003, "项目标识只能包含小写字母、数字,以及“-”和“_”符号,并且只能小写字母开头") + c.JsonResult(6003, i18n.Tr(c.Lang, "message.project_id_tips")) } if !models.NewItemsets().Exist(itemId) { - c.JsonResult(6007, "项目空间不存在") + c.JsonResult(6007, i18n.Tr(c.Lang, "message.project_space_not_exist")) } if strings.Count(identify, "") > 50 { - c.JsonResult(6004, "文档标识不能超过50字") + c.JsonResult(6004, i18n.Tr(c.Lang, "message.project_id_length")) } ext := filepath.Ext(moreFile.Filename) @@ -610,7 +611,7 @@ func (c *BookController) Import() { } if books, _ := models.NewBook().FindByField("identify", identify, "book_id"); len(books) > 0 { - c.JsonResult(6006, "项目标识已存在") + c.JsonResult(6006, i18n.Tr(c.Lang, "message.project_id_existed")) } tempPath := filepath.Join(os.TempDir(), c.CruSession.SessionID()) diff --git a/controllers/DocumentController.go b/controllers/DocumentController.go index a6f1a0dd..158a5556 100644 --- a/controllers/DocumentController.go +++ b/controllers/DocumentController.go @@ -17,6 +17,7 @@ import ( "github.com/astaxie/beego" "github.com/astaxie/beego/logs" "github.com/astaxie/beego/orm" + "github.com/beego/i18n" "github.com/boombuler/barcode" "github.com/boombuler/barcode/qr" "github.com/mindoc-org/mindoc/conf" @@ -42,7 +43,7 @@ func (c *DocumentController) Index() { token := c.GetString("token") if identify == "" { - c.ShowErrorPage(404, "项目不存在或已删除") + c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.item_not_exist")) } // 如果没有开启匿名访问则跳转到登录 @@ -67,7 +68,7 @@ func (c *DocumentController) Index() { c.Data["Description"] = utils.AutoSummary(doc.Release, 120) } } else { - c.Data["Title"] = "概要" + c.Data["Title"] = i18n.Tr(c.Lang, "blog.summary") c.Data["Content"] = template.HTML(blackfriday.Run([]byte(bookResult.Description))) } @@ -75,10 +76,10 @@ func (c *DocumentController) Index() { if err != nil { if err == orm.ErrNoRows { - c.ShowErrorPage(404, "当前项目没有文档") + c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.no_doc_in_cur_proj")) } else { logs.Error("生成项目文档树时出错 -> ", err) - c.ShowErrorPage(500, "生成项目文档树时出错") + c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.build_doc_tree_error")) } } c.Data["Model"] = bookResult @@ -97,7 +98,7 @@ func (c *DocumentController) Read() { c.Data["DocumentId"] = id if identify == "" || id == "" { - c.ShowErrorPage(404, "项目不存或已删除") + c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.item_not_exist")) } // 如果没有开启匿名访问则跳转到登录 @@ -116,24 +117,24 @@ func (c *DocumentController) Read() { doc, err = doc.FromCacheById(docId) if err != nil || doc == nil { logs.Error("从缓存中读取文档时失败 ->", err) - c.ShowErrorPage(404, "文档不存在或已删除") + c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.doc_not_exist")) return } } else { doc, err = doc.FromCacheByIdentify(id, bookResult.BookId) if err != nil || doc == nil { if err == orm.ErrNoRows { - c.ShowErrorPage(404, "文档不存在或已删除") + c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.doc_not_exist")) } else { - logs.Error("从缓存查询文档时出错 ->", err) - c.ShowErrorPage(500, "未知异常") + logs.Error("从数据库查询文档时出错 ->", err) + c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.unknown_exception")) } return } } if doc.BookId != bookResult.BookId { - c.ShowErrorPage(404, "文档不存在或已删除") + c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.doc_not_exist")) } doc.Processor() @@ -163,7 +164,7 @@ func (c *DocumentController) Read() { if err != nil && err != orm.ErrNoRows { logs.Error("生成项目文档树时出错 ->", err) - c.ShowErrorPage(500, "生成项目文档树时出错") + c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.build_doc_tree_error")) } c.Data["Description"] = utils.AutoSummary(doc.Release, 120) @@ -180,7 +181,7 @@ func (c *DocumentController) Edit() { identify := c.Ctx.Input.Param(":key") if identify == "" { - c.ShowErrorPage(404, "无法解析项目标识") + c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.project_id_error")) } bookResult := models.NewBookResult() @@ -190,7 +191,7 @@ func (c *DocumentController) Edit() { if c.Member.IsAdministrator() { book, err := models.NewBook().FindByFieldFirst("identify", identify) if err != nil { - c.JsonResult(6002, "项目不存在或权限不足") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_exist_or_no_permit")) } bookResult = models.NewBookResult().ToBookResult(*book) @@ -199,15 +200,15 @@ func (c *DocumentController) Edit() { if err != nil { if err == orm.ErrNoRows || err == models.ErrPermissionDenied { - c.ShowErrorPage(403, "项目不存在或没有权限") + c.ShowErrorPage(403, i18n.Tr(c.Lang, "message.item_not_exist_or_no_permit")) } else { logs.Error("查询项目时出错 -> ", err) - c.ShowErrorPage(500, "查询项目时出错") + c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.system_error")) } return } if bookResult.RoleId == conf.BookObserver { - c.JsonResult(6002, "项目不存在或权限不足") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_exist_or_no_permit")) } } @@ -261,11 +262,11 @@ func (c *DocumentController) Create() { isOpen, _ := c.GetInt("is_open", 0) if identify == "" { - c.JsonResult(6001, "参数错误") + c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error")) } if docName == "" { - c.JsonResult(6004, "文档名称不能为空") + c.JsonResult(6004, i18n.Tr(c.Lang, "message.doc_name_empty")) } bookId := 0 @@ -275,7 +276,7 @@ func (c *DocumentController) Create() { book, err := models.NewBook().FindByFieldFirst("identify", identify) if err != nil { logs.Error(err) - c.JsonResult(6002, "项目不存在或权限不足") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_existed_or_no_permit")) } bookId = book.BookId @@ -284,7 +285,7 @@ func (c *DocumentController) Create() { if err != nil || bookResult.RoleId == conf.BookObserver { logs.Error("FindByIdentify => ", err) - c.JsonResult(6002, "项目不存在或权限不足") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_existed_or_no_permit")) } bookId = bookResult.BookId @@ -292,18 +293,18 @@ func (c *DocumentController) Create() { if docIdentify != "" { if ok, err := regexp.MatchString(`[a-z]+[a-zA-Z0-9_.\-]*$`, docIdentify); !ok || err != nil { - c.JsonResult(6003, "文档标识只能包含小写字母、数字,以及“-”、“.”和“_”符号") + c.JsonResult(6003, i18n.Tr(c.Lang, "message.project_id_tips")) } d, _ := models.NewDocument().FindByIdentityFirst(docIdentify, bookId) if d.DocumentId > 0 && d.DocumentId != docId { - c.JsonResult(6006, "文档标识已被使用") + c.JsonResult(6006, i18n.Tr(c.Lang, "message.project_id_existed")) } } if parentId > 0 { doc, err := models.NewDocument().Find(parentId) if err != nil || doc.BookId != bookId { - c.JsonResult(6003, "父分类不存在") + c.JsonResult(6003, i18n.Tr(c.Lang, "message.parent_id_not_existed")) } } @@ -328,7 +329,7 @@ func (c *DocumentController) Create() { if err := document.InsertOrUpdate(); err != nil { logs.Error("添加或更新文档时出错 -> ", err) - c.JsonResult(6005, "保存失败") + c.JsonResult(6005, i18n.Tr(c.Lang, "message.failed")) } else { c.JsonResult(0, "ok", document) } @@ -341,7 +342,7 @@ func (c *DocumentController) Upload() { isAttach := true if identify == "" { - c.JsonResult(6001, "参数错误") + c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error")) } name := "editormd-file-file" @@ -351,7 +352,7 @@ func (c *DocumentController) Upload() { name = "editormd-image-file" file, moreFile, err = c.GetFile(name) if err == http.ErrMissingFile || moreFile == nil { - c.JsonResult(6003, "没有发现需要上传的文件") + c.JsonResult(6003, i18n.Tr(c.Lang, "message.upload_file_empty")) return } } @@ -367,17 +368,17 @@ func (c *DocumentController) Upload() { } if conf.GetUploadFileSize() > 0 && moreFile.Size > conf.GetUploadFileSize() { - c.JsonResult(6009, "文件大小超过了限定的最大值") + c.JsonResult(6009, i18n.Tr(c.Lang, "message.upload_file_size_limit")) } ext := filepath.Ext(moreFile.Filename) //文件必须带有后缀名 if ext == "" { - c.JsonResult(6003, "无法解析文件的格式") + c.JsonResult(6003, i18n.Tr(c.Lang, "message.upload_file_type_error")) } //如果文件类型设置为 * 标识不限制文件类型 if conf.IsAllowUploadFileExt(ext) == false { - c.JsonResult(6004, "不允许的文件类型") + c.JsonResult(6004, i18n.Tr(c.Lang, "message.upload_file_type_error")) } bookId := 0 @@ -387,7 +388,7 @@ func (c *DocumentController) Upload() { book, err := models.NewBook().FindByFieldFirst("identify", identify) if err != nil { - c.JsonResult(6006, "文档不存在或权限不足") + c.JsonResult(6006, i18n.Tr(c.Lang, "message.doc_not_exist_or_no_permit")) } bookId = book.BookId @@ -397,7 +398,7 @@ func (c *DocumentController) Upload() { if err != nil { logs.Error("DocumentController.Edit => ", err) if err == orm.ErrNoRows { - c.JsonResult(6006, "权限不足") + c.JsonResult(6006, i18n.Tr(c.Lang, "message.no_permission")) } c.JsonResult(6001, err.Error()) @@ -405,7 +406,7 @@ func (c *DocumentController) Upload() { // 如果没有编辑权限 if book.RoleId != conf.BookEditor && book.RoleId != conf.BookAdmin && book.RoleId != conf.BookFounder { - c.JsonResult(6006, "权限不足") + c.JsonResult(6006, i18n.Tr(c.Lang, "message.no_permission")) } bookId = book.BookId @@ -414,11 +415,11 @@ func (c *DocumentController) Upload() { if docId > 0 { doc, err := models.NewDocument().Find(docId) if err != nil { - c.JsonResult(6007, "文档不存在") + c.JsonResult(6007, i18n.Tr(c.Lang, "message.doc_not_exist")) } if doc.BookId != bookId { - c.JsonResult(6008, "文档不属于指定的项目") + c.JsonResult(6008, i18n.Tr(c.Lang, "message.doc_not_belong_project")) } } @@ -440,7 +441,7 @@ func (c *DocumentController) Upload() { if err != nil { logs.Error("保存文件失败 -> ", err) - c.JsonResult(6005, "保存文件失败") + c.JsonResult(6005, i18n.Tr(c.Lang, "message.failed")) } attachment := models.NewAttachment() @@ -473,7 +474,7 @@ func (c *DocumentController) Upload() { if err != nil { os.Remove(filePath) logs.Error("文件保存失败 ->", err) - c.JsonResult(6006, "文件保存失败") + c.JsonResult(6006, i18n.Tr(c.Lang, "message.failed")) } if attachment.HttpPath == "" { @@ -481,7 +482,7 @@ func (c *DocumentController) Upload() { if err := attachment.Update(); err != nil { logs.Error("保存文件失败 ->", err) - c.JsonResult(6005, "保存文件失败") + c.JsonResult(6005, i18n.Tr(c.Lang, "message.failed")) } } @@ -523,10 +524,10 @@ func (c *DocumentController) DownloadAttachment() { book, err := models.NewBook().FindByFieldFirst("identify", identify) if err != nil { if err == orm.ErrNoRows { - c.ShowErrorPage(404, "项目不存在或已删除") + c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.item_not_exist")) } else { logs.Error("查找项目时出错 ->", err) - c.ShowErrorPage(500, "系统错误") + c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.system_error")) } } @@ -534,7 +535,7 @@ func (c *DocumentController) DownloadAttachment() { if c.Member == nil || c.Member.Role != conf.MemberSuperRole { // 如果项目是私有的,并且 token 不正确 if (book.PrivatelyOwned == 1 && token == "") || (book.PrivatelyOwned == 1 && book.PrivateToken != token) { - c.ShowErrorPage(403, "权限不足") + c.ShowErrorPage(403, i18n.Tr(c.Lang, "message.no_permission")) } } @@ -549,14 +550,14 @@ func (c *DocumentController) DownloadAttachment() { if err != nil { logs.Error("查找附件时出错 -> ", err) if err == orm.ErrNoRows { - c.ShowErrorPage(404, "附件不存在或已删除") + c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.attachment_not_exist")) } else { - c.ShowErrorPage(500, "查找附件时出错") + c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.system_error")) } } if attachment.BookId != bookId { - c.ShowErrorPage(404, "附件不存在或已删除") + c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.attachment_not_exist")) } c.Ctx.Output.Download(filepath.Join(conf.WorkingDirectory, attachment.FilePath), attachment.FileName) @@ -569,39 +570,39 @@ func (c *DocumentController) RemoveAttachment() { attachId, _ := c.GetInt("attach_id") if attachId <= 0 { - c.JsonResult(6001, "参数错误") + c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error")) } attach, err := models.NewAttachment().Find(attachId) if err != nil { logs.Error(err) - c.JsonResult(6002, "附件不存在") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.attachment_not_exist")) } document, err := models.NewDocument().Find(attach.DocumentId) if err != nil { logs.Error(err) - c.JsonResult(6003, "文档不存在") + c.JsonResult(6003, i18n.Tr(c.Lang, "message.doc_not_exist")) } if c.Member.Role != conf.MemberSuperRole { rel, err := models.NewRelationship().FindByBookIdAndMemberId(document.BookId, c.Member.MemberId) if err != nil { logs.Error(err) - c.JsonResult(6004, "权限不足") + c.JsonResult(6004, i18n.Tr(c.Lang, "message.no_permission")) } if rel.RoleId == conf.BookObserver { - c.JsonResult(6004, "权限不足") + c.JsonResult(6004, i18n.Tr(c.Lang, "message.no_permission")) } } err = attach.Delete() if err != nil { logs.Error(err) - c.JsonResult(6005, "删除失败") + c.JsonResult(6005, i18n.Tr(c.Lang, "message.failed")) } os.Remove(filepath.Join(conf.WorkingDirectory, attach.FilePath)) @@ -623,7 +624,7 @@ func (c *DocumentController) Delete() { book, err := models.NewBook().FindByFieldFirst("identify", identify) if err != nil { logs.Error("FindByIdentify => ", err) - c.JsonResult(6002, "项目不存在或权限不足") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_exist_or_no_permit")) } bookId = book.BookId @@ -632,31 +633,31 @@ func (c *DocumentController) Delete() { if err != nil || bookResult.RoleId == conf.BookObserver { logs.Error("FindByIdentify => ", err) - c.JsonResult(6002, "项目不存在或权限不足") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_exist_or_no_permit")) } bookId = bookResult.BookId } if docId <= 0 { - c.JsonResult(6001, "参数错误") + c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error")) } doc, err := models.NewDocument().Find(docId) if err != nil { logs.Error("Delete => ", err) - c.JsonResult(6003, "删除失败") + c.JsonResult(6003, i18n.Tr(c.Lang, "message.failed")) } // 如果文档所属项目错误 if doc.BookId != bookId { - c.JsonResult(6004, "参数错误") + c.JsonResult(6004, i18n.Tr(c.Lang, "message.param_error")) } // 递归删除项目下的文档以及子文档 err = doc.RecursiveDocument(doc.DocumentId) if err != nil { - c.JsonResult(6005, "删除失败") + c.JsonResult(6005, i18n.Tr(c.Lang, "message.failed")) } // 重置文档数量统计 @@ -682,7 +683,7 @@ func (c *DocumentController) Content() { if c.Member.IsAdministrator() { book, err := models.NewBook().FindByFieldFirst("identify", identify) if err != nil || book == nil { - c.JsonResult(6002, "项目不存在或权限不足") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_exist_or_no_permit")) return } @@ -693,7 +694,7 @@ func (c *DocumentController) Content() { if err != nil || bookResult.RoleId == conf.BookObserver { logs.Error("项目不存在或权限不足 -> ", err) - c.JsonResult(6002, "项目不存在或权限不足") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_exist_or_no_permit")) } bookId = bookResult.BookId @@ -701,7 +702,7 @@ func (c *DocumentController) Content() { } if docId <= 0 { - c.JsonResult(6001, "参数错误") + c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error")) } if c.Ctx.Input.IsPost() { @@ -713,17 +714,17 @@ func (c *DocumentController) Content() { doc, err := models.NewDocument().Find(docId) if err != nil || doc == nil { - c.JsonResult(6003, "读取文档错误") + c.JsonResult(6003, i18n.Tr(c.Lang, "message.read_file_error")) return } if doc.BookId != bookId { - c.JsonResult(6004, "保存的文档不属于指定项目") + c.JsonResult(6004, i18n.Tr(c.Lang, "message.dock_not_belong_project")) } if doc.Version != version && !strings.EqualFold(isCover, "yes") { logs.Info("%d|", version, doc.Version) - c.JsonResult(6005, "文档已被修改确定要覆盖吗?") + c.JsonResult(6005, i18n.Tr(c.Lang, "message.confirm_override_doc")) } history := models.NewDocumentHistory() @@ -736,7 +737,7 @@ func (c *DocumentController) Content() { history.ParentId = doc.ParentId history.Version = time.Now().Unix() history.Action = "modify" - history.ActionName = "修改文档" + history.ActionName = i18n.Tr(c.Lang, "doc.modify_doc") if markdown == "" && content != "" { doc.Markdown = content @@ -750,7 +751,7 @@ func (c *DocumentController) Content() { if err := doc.InsertOrUpdate(); err != nil { logs.Error("InsertOrUpdate => ", err) - c.JsonResult(6006, "保存失败") + c.JsonResult(6006, i18n.Tr(c.Lang, "message.failed")) } // 如果启用了文档历史,则添加历史文档 @@ -769,7 +770,7 @@ func (c *DocumentController) Content() { go func() { err := doc.ReleaseContent() if err == nil { - logs.Informational("文档自动发布成功 -> document_id=%d;document_name=%s", doc.DocumentId, doc.DocumentName) + logs.Informational(i18n.Tr(c.Lang, "message.doc_auto_published")+"-> document_id=%d;document_name=%s", doc.DocumentId, doc.DocumentName) } }() } @@ -779,7 +780,7 @@ func (c *DocumentController) Content() { doc, err := models.NewDocument().Find(docId) if err != nil { - c.JsonResult(6003, "文档不存在") + c.JsonResult(6003, i18n.Tr(c.Lang, "message.doc_not_exist")) return } @@ -797,7 +798,7 @@ func (c *DocumentController) Export() { identify := c.Ctx.Input.Param(":key") if identify == "" { - c.ShowErrorPage(500, "参数错误") + c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.param_error")) } output := c.GetString("output") @@ -809,7 +810,7 @@ func (c *DocumentController) Export() { return } if !conf.GetEnableExport() { - c.ShowErrorPage(500, "系统没有开启导出功能") + c.ShowErrorPage(500, i18n.Tr(c.Lang, "export_func_disable")) } bookResult := models.NewBookResult() @@ -817,10 +818,10 @@ func (c *DocumentController) Export() { book, err := models.NewBook().FindByIdentify(identify) if err != nil { if err == orm.ErrNoRows { - c.ShowErrorPage(404, "项目不存在") + c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.item_not_exist")) } else { logs.Error("查找项目时出错 ->", err) - c.ShowErrorPage(500, "查找项目时出错") + c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.system_error")) } } bookResult = models.NewBookResult().ToBookResult(*book) @@ -828,7 +829,7 @@ func (c *DocumentController) Export() { bookResult = c.isReadable(identify, token) } if !bookResult.IsDownload { - c.ShowErrorPage(200, "当前项目没有开启导出功能") + c.ShowErrorPage(200, i18n.Tr(c.Lang, "message.cur_project_export_func_disable")) } if !strings.HasPrefix(bookResult.Cover, "http:://") && !strings.HasPrefix(bookResult.Cover, "https:://") { @@ -837,12 +838,12 @@ func (c *DocumentController) Export() { if output == "markdown" { if bookResult.Editor != "markdown" { - c.ShowErrorPage(500, "当前项目不支持Markdown编辑器") + c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.cur_project_not_support_md")) } p, err := bookResult.ExportMarkdown(c.CruSession.SessionID()) if err != nil { - c.ShowErrorPage(500, "导出文档失败") + c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.failed")) } c.Ctx.Output.Download(p, bookResult.BookName+".zip") @@ -875,15 +876,15 @@ func (c *DocumentController) Export() { } else if output == "pdf" || output == "epub" || output == "docx" || output == "mobi" { if err := models.BackgroundConvert(c.CruSession.SessionID(), bookResult); err != nil && err != gopool.ErrHandlerIsExist { - c.ShowErrorPage(500, "导出失败,请查看系统日志") + c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.export_failed")) } - c.ShowErrorPage(200, "文档正在后台转换,请稍后再下载") + c.ShowErrorPage(200, i18n.Tr(c.Lang, "message.file_converting")) } else { - c.ShowErrorPage(200, "不支持的文件格式") + c.ShowErrorPage(200, i18n.Tr(c.Lang, "message.unsupport_file_type")) } - c.ShowErrorPage(404, "项目没有导出文件") + c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.no_exportable_file")) } // 生成项目访问的二维码 @@ -894,20 +895,20 @@ func (c *DocumentController) QrCode() { book, err := models.NewBook().FindByIdentify(identify) if err != nil || book.BookId <= 0 { - c.ShowErrorPage(404, "项目不存在") + c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.item_not_exist")) } uri := conf.URLFor("DocumentController.Index", ":key", identify) code, err := qr.Encode(uri, qr.L, qr.Unicode) if err != nil { logs.Error("生成二维码失败 ->", err) - c.ShowErrorPage(500, "生成二维码失败") + c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.gen_qrcode_failed")) } code, err = barcode.Scale(code, 150, 150) if err != nil { logs.Error("生成二维码失败 ->", err) - c.ShowErrorPage(500, "生成二维码失败") + c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.gen_qrcode_failed")) } c.Ctx.ResponseWriter.Header().Set("Content-Type", "image/png") @@ -917,7 +918,7 @@ func (c *DocumentController) QrCode() { err = png.Encode(c.Ctx.ResponseWriter, code) if err != nil { logs.Error("生成二维码失败 ->", err) - c.ShowErrorPage(500, "生成二维码失败") + c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.gen_qrcode_failed")) } } @@ -930,7 +931,7 @@ func (c *DocumentController) Search() { keyword := strings.TrimSpace(c.GetString("keyword")) if identify == "" { - c.JsonResult(6001, "参数错误") + c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error")) } if !c.EnableAnonymous && !c.isUserLoggedIn() { @@ -943,11 +944,11 @@ func (c *DocumentController) Search() { docs, err := models.NewDocumentSearchResult().SearchDocument(keyword, bookResult.BookId) if err != nil { logs.Error(err) - c.JsonResult(6002, "搜索结果错误") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.search_result_error")) } if len(docs) < 0 { - c.JsonResult(404, "没有数据库") + c.JsonResult(404, i18n.Tr(c.Lang, "message.no_data")) } for _, doc := range docs { @@ -977,7 +978,7 @@ func (c *DocumentController) History() { book, err := models.NewBook().FindByFieldFirst("identify", identify) if err != nil { logs.Error("查找项目失败 ->", err) - c.Data["ErrorMessage"] = "项目不存在或权限不足" + c.Data["ErrorMessage"] = i18n.Tr(c.Lang, "message.item_not_exist_or_no_permit") return } @@ -987,7 +988,7 @@ func (c *DocumentController) History() { bookResult, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId) if err != nil || bookResult.RoleId == conf.BookObserver { logs.Error("查找项目失败 ->", err) - c.Data["ErrorMessage"] = "项目不存在或权限不足" + c.Data["ErrorMessage"] = i18n.Tr(c.Lang, "message.item_not_exist_or_no_permit") return } @@ -996,27 +997,27 @@ func (c *DocumentController) History() { } if docId <= 0 { - c.Data["ErrorMessage"] = "参数错误" + c.Data["ErrorMessage"] = i18n.Tr(c.Lang, "message.param_error") return } doc, err := models.NewDocument().Find(docId) if err != nil { logs.Error("Delete => ", err) - c.Data["ErrorMessage"] = "获取历史失败" + c.Data["ErrorMessage"] = i18n.Tr(c.Lang, "message.get_doc_his_failed") return } // 如果文档所属项目错误 if doc.BookId != bookId { - c.Data["ErrorMessage"] = "参数错误" + c.Data["ErrorMessage"] = i18n.Tr(c.Lang, "message.param_error") return } histories, totalCount, err := models.NewDocumentHistory().FindToPager(docId, pageIndex, conf.PageSize) if err != nil { logs.Error("分页查找文档历史失败 ->", err) - c.Data["ErrorMessage"] = "获取历史失败" + c.Data["ErrorMessage"] = i18n.Tr(c.Lang, "message.get_doc_his_failed") return } @@ -1040,7 +1041,7 @@ func (c *DocumentController) DeleteHistory() { historyId, _ := c.GetInt("history_id", 0) if historyId <= 0 { - c.JsonResult(6001, "参数错误") + c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error")) } bookId := 0 @@ -1050,7 +1051,7 @@ func (c *DocumentController) DeleteHistory() { book, err := models.NewBook().FindByFieldFirst("identify", identify) if err != nil { logs.Error("查找项目失败 ->", err) - c.JsonResult(6002, "项目不存在或权限不足") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_exist_or_no_permit")) } bookId = book.BookId @@ -1058,31 +1059,31 @@ func (c *DocumentController) DeleteHistory() { bookResult, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId) if err != nil || bookResult.RoleId == conf.BookObserver { logs.Error("查找项目失败 ->", err) - c.JsonResult(6002, "项目不存在或权限不足") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_exist_or_no_permit")) } bookId = bookResult.BookId } if docId <= 0 { - c.JsonResult(6001, "参数错误") + c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error")) } doc, err := models.NewDocument().Find(docId) if err != nil { logs.Error("Delete => ", err) - c.JsonResult(6001, "获取历史失败") + c.JsonResult(6001, i18n.Tr(c.Lang, "message.get_doc_his_failed")) } // 如果文档所属项目错误 if doc.BookId != bookId { - c.JsonResult(6001, "参数错误") + c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error")) } err = models.NewDocumentHistory().Delete(historyId, docId) if err != nil { logs.Error(err) - c.JsonResult(6002, "删除失败") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.failed")) } c.JsonResult(0, "ok") @@ -1099,7 +1100,7 @@ func (c *DocumentController) RestoreHistory() { historyId, _ := c.GetInt("history_id", 0) if historyId <= 0 { - c.JsonResult(6001, "参数错误") + c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error")) } bookId := 0 @@ -1108,7 +1109,7 @@ func (c *DocumentController) RestoreHistory() { book, err := models.NewBook().FindByFieldFirst("identify", identify) if err != nil { logs.Error("FindByIdentify => ", err) - c.JsonResult(6002, "项目不存在或权限不足") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_exist_or_no_permit")) } bookId = book.BookId @@ -1116,31 +1117,31 @@ func (c *DocumentController) RestoreHistory() { bookResult, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId) if err != nil || bookResult.RoleId == conf.BookObserver { logs.Error("FindByIdentify => ", err) - c.JsonResult(6002, "项目不存在或权限不足") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_exist_or_no_permit")) } bookId = bookResult.BookId } if docId <= 0 { - c.JsonResult(6001, "参数错误") + c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error")) } doc, err := models.NewDocument().Find(docId) if err != nil { logs.Error("Delete => ", err) - c.JsonResult(6001, "获取历史失败") + c.JsonResult(6001, i18n.Tr(c.Lang, "message.get_doc_his_failed")) } // 如果文档所属项目错误 if doc.BookId != bookId { - c.JsonResult(6001, "参数错误") + c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error")) } err = models.NewDocumentHistory().Restore(historyId, docId, c.Member.MemberId) if err != nil { logs.Error(err) - c.JsonResult(6002, "删除失败") + c.JsonResult(6002, i18n.Tr(c.Lang, "message.failed")) } c.JsonResult(0, "ok", doc) @@ -1162,7 +1163,7 @@ func (c *DocumentController) Compare() { book, err := models.NewBook().FindByFieldFirst("identify", identify) if err != nil { logs.Error("DocumentController.Compare => ", err) - c.ShowErrorPage(403, "权限不足") + c.ShowErrorPage(403, i18n.Tr(c.Lang, "message.no_permission")) return } @@ -1173,7 +1174,7 @@ func (c *DocumentController) Compare() { bookResult, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId) if err != nil || bookResult.RoleId == conf.BookObserver { logs.Error("FindByIdentify => ", err) - c.ShowErrorPage(403, "权限不足") + c.ShowErrorPage(403, i18n.Tr(c.Lang, "message.no_permission")) return } @@ -1183,7 +1184,7 @@ func (c *DocumentController) Compare() { } if historyId <= 0 { - c.ShowErrorPage(60002, "参数错误") + c.ShowErrorPage(60002, i18n.Tr(c.Lang, "message.param_error")) } history, err := models.NewDocumentHistory().Find(historyId) @@ -1194,7 +1195,7 @@ func (c *DocumentController) Compare() { doc, err := models.NewDocument().Find(history.DocumentId) if err != nil || doc == nil || doc.BookId != bookId { - c.ShowErrorPage(60002, "文档不存在或已删除") + c.ShowErrorPage(60002, i18n.Tr(c.Lang, "message.doc_not_exist")) return } @@ -1216,7 +1217,7 @@ func (c *DocumentController) isReadable(identify, token string) *models.BookResu if err != nil { logs.Error(err) - c.ShowErrorPage(500, "项目不存在") + c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.item_not_exist")) } bookResult := models.NewBookResult().ToBookResult(*book) isOk := false @@ -1241,13 +1242,13 @@ func (c *DocumentController) isReadable(identify, token string) *models.BookResu c.SetSession(identify, token) } else if token, ok := c.GetSession(identify).(string); !ok || !strings.EqualFold(token, book.PrivateToken) { logs.Info("尝试访问文档但权限不足 ->", identify, token) - c.ShowErrorPage(403, "权限不足") + c.ShowErrorPage(403, i18n.Tr(c.Lang, "message.no_permission")) } } else if password := c.GetString("bPassword", ""); !isOk && book.BookPassword != "" && password != "" { //如果设置了密码,则判断密码是否正确 if book.BookPassword != password { - c.JsonResult(5001, "密码错误") + c.JsonResult(5001, i18n.Tr(c.Lang, "message.wrong_password")) } else { c.SetSession(identify, password) c.JsonResult(0, "OK") @@ -1266,7 +1267,7 @@ func (c *DocumentController) isReadable(identify, token string) *models.BookResu } } else { logs.Info("尝试访问文档但权限不足 ->", identify, token) - c.ShowErrorPage(403, "权限不足") + c.ShowErrorPage(403, i18n.Tr(c.Lang, "message.no_permission")) } } } @@ -1280,7 +1281,7 @@ func promptUserToLogIn(c *DocumentController) { logs.Info(" Access will be redirected to login page(SessionId: " + c.CruSession.SessionID() + ").") if c.IsAjax() { - c.JsonResult(6000, "请重新登录。") + c.JsonResult(6000, i18n.Tr(c.Lang, "message.need_relogin")) } else { c.Redirect(conf.URLFor("AccountController.Login")+"?url="+url.PathEscape(conf.BaseUrl+c.Ctx.Request.URL.RequestURI()), 302) } diff --git a/views/book/team.tpl b/views/book/team.tpl index 97cfbf73..2f227665 100644 --- a/views/book/team.tpl +++ b/views/book/team.tpl @@ -50,7 +50,7 @@