add translation for ribbon widgets: image_properties.js

This commit is contained in:
Nriver 2024-08-05 10:40:08 +08:00
parent e2aaa97a01
commit 6743eb8d1b
3 changed files with 39 additions and 15 deletions

View File

@ -3,34 +3,35 @@ import NoteContextAwareWidget from "../note_context_aware_widget.js";
import toastService from "../../services/toast.js"; import toastService from "../../services/toast.js";
import openService from "../../services/open.js"; import openService from "../../services/open.js";
import utils from "../../services/utils.js"; import utils from "../../services/utils.js";
import { t } from "../../services/i18n.js";
const TPL = ` const TPL = `
<div class="image-properties"> <div class="image-properties">
<div style="display: flex; justify-content: space-evenly; margin: 10px;"> <div style="display: flex; justify-content: space-evenly; margin: 10px;">
<span> <span>
<strong>Original file name:</strong> <strong>${t("image_properties.original_file_name")}:</strong>
<span class="image-filename"></span> <span class="image-filename"></span>
</span> </span>
<span> <span>
<strong>File type:</strong> <strong>${t("image_properties.file_type")}:</strong>
<span class="image-filetype"></span> <span class="image-filetype"></span>
</span> </span>
<span> <span>
<strong>File size:</strong> <strong>${t("image_properties.file_size")}:</strong>
<span class="image-filesize"></span> <span class="image-filesize"></span>
</span> </span>
</div> </div>
<div class="no-print" style="display: flex; justify-content: space-evenly; margin: 10px;"> <div class="no-print" style="display: flex; justify-content: space-evenly; margin: 10px;">
<button class="image-download btn btn-sm btn-primary" type="button">Download</button> <button class="image-download btn btn-sm btn-primary" type="button">${t("image_properties.download")}</button>
<button class="image-open btn btn-sm btn-primary" type="button">Open</button> <button class="image-open btn btn-sm btn-primary" type="button">${t("image_properties.open")}</button>
<button class="image-copy-reference-to-clipboard btn btn-sm btn-primary" type="button">Copy reference to clipboard</button> <button class="image-copy-reference-to-clipboard btn btn-sm btn-primary" type="button">${t("image_properties.copy_reference_to_clipboard")}</button>
<button class="image-upload-new-revision btn btn-sm btn-primary" type="button">Upload new revision</button> <button class="image-upload-new-revision btn btn-sm btn-primary" type="button">${t("image_properties.upload_new_revision")}</button>
</div> </div>
<input type="file" class="image-upload-new-revision-input" style="display: none"> <input type="file" class="image-upload-new-revision-input" style="display: none">
@ -53,7 +54,7 @@ export default class ImagePropertiesWidget extends NoteContextAwareWidget {
return { return {
show: this.isEnabled(), show: this.isEnabled(),
activate: true, activate: true,
title: 'Image', title: t("image_properties.title"),
icon: 'bx bx-image' icon: 'bx bx-image'
}; };
} }
@ -89,14 +90,13 @@ export default class ImagePropertiesWidget extends NoteContextAwareWidget {
const result = await server.upload(`images/${this.noteId}`, fileToUpload); const result = await server.upload(`images/${this.noteId}`, fileToUpload);
if (result.uploaded) { if (result.uploaded) {
toastService.showMessage("New image revision has been uploaded."); toastService.showMessage(t("image_properties.upload_success"));
await utils.clearBrowserCache(); await utils.clearBrowserCache();
this.refresh(); this.refresh();
} } else {
else { toastService.showError(t("image_properties.upload_failed", { message: result.message }));
toastService.showError(`Upload of a new image revision failed: ${result.message}`);
} }
}); });
} }

View File

@ -685,9 +685,21 @@
"file_size": "文件大小", "file_size": "文件大小",
"download": "下载", "download": "下载",
"open": "打开", "open": "打开",
"upload_new_revision": "上传新修改", "upload_new_revision": "上传新版本",
"upload_success": "新文件修改已上传。", "upload_success": "新文件版本已上传。",
"upload_failed": "新文件修改上传失败。", "upload_failed": "新文件版本上传失败。",
"title": "文件" "title": "文件"
},
"image_properties": {
"original_file_name": "原始文件名",
"file_type": "文件类型",
"file_size": "文件大小",
"download": "下载",
"open": "打开",
"copy_reference_to_clipboard": "复制引用到剪贴板",
"upload_new_revision": "上传新版本",
"upload_success": "新图像版本已上传。",
"upload_failed": "新图像版本上传失败:{{message}}",
"title": "图像"
} }
} }

View File

@ -690,5 +690,17 @@
"upload_success": "New file revision has been uploaded.", "upload_success": "New file revision has been uploaded.",
"upload_failed": "Upload of a new file revision failed.", "upload_failed": "Upload of a new file revision failed.",
"title": "File" "title": "File"
},
"image_properties": {
"original_file_name": "Original file name",
"file_type": "File type",
"file_size": "File size",
"download": "Download",
"open": "Open",
"copy_reference_to_clipboard": "Copy reference to clipboard",
"upload_new_revision": "Upload new revision",
"upload_success": "New image revision has been uploaded.",
"upload_failed": "Upload of a new image revision failed: {{message}}",
"title": "Image"
} }
} }