add translation for ribbon widgets: file_properties.js

This commit is contained in:
Nriver 2024-08-05 10:32:48 +08:00
parent 4270ab416e
commit c2a8f4f4a3
3 changed files with 38 additions and 14 deletions

View File

@ -4,6 +4,7 @@ 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 protectedSessionHolder from "../../services/protected_session_holder.js"; import protectedSessionHolder from "../../services/protected_session_holder.js";
import { t } from "../../services/i18n.js";
const TPL = ` const TPL = `
<div class="file-properties-widget"> <div class="file-properties-widget">
@ -27,26 +28,26 @@ const TPL = `
<table class="file-table"> <table class="file-table">
<tr> <tr>
<th>Note ID:</th> <th>${t("file_properties.note_id")}:</th>
<td class="file-note-id"></td> <td class="file-note-id"></td>
<th>Original file name:</th> <th>${t("file_properties.original_file_name")}:</th>
<td class="file-filename"></td> <td class="file-filename"></td>
</tr> </tr>
<tr> <tr>
<th>File type:</th> <th>${t("file_properties.file_type")}:</th>
<td class="file-filetype"></td> <td class="file-filetype"></td>
<th>File size:</th> <th>${t("file_properties.file_size")}:</th>
<td class="file-filesize"></td> <td class="file-filesize"></td>
</tr> </tr>
<tr> <tr>
<td colspan="4"> <td colspan="4">
<div class="file-buttons"> <div class="file-buttons">
<button class="file-download btn btn-sm btn-primary" type="button">Download</button> <button class="file-download btn btn-sm btn-primary" type="button">${t("file_properties.download")}</button>
&nbsp; &nbsp;
<button class="file-open btn btn-sm btn-primary" type="button">Open</button> <button class="file-open btn btn-sm btn-primary" type="button">${t("file_properties.open")}</button>
&nbsp; &nbsp;
<button class="file-upload-new-revision btn btn-sm btn-primary">Upload new revision</button> <button class="file-upload-new-revision btn btn-sm btn-primary">${t("file_properties.upload_new_revision")}</button>
<input type="file" class="file-upload-new-revision-input" style="display: none"> <input type="file" class="file-upload-new-revision-input" style="display: none">
</div> </div>
@ -72,7 +73,7 @@ export default class FilePropertiesWidget extends NoteContextAwareWidget {
return { return {
show: this.isEnabled(), show: this.isEnabled(),
activate: true, activate: true,
title: 'File', title: t("file_properties.title"),
icon: 'bx bx-file' icon: 'bx bx-file'
}; };
} }
@ -103,12 +104,11 @@ export default class FilePropertiesWidget extends NoteContextAwareWidget {
const result = await server.upload(`notes/${this.noteId}/file`, fileToUpload); const result = await server.upload(`notes/${this.noteId}/file`, fileToUpload);
if (result.uploaded) { if (result.uploaded) {
toastService.showMessage("New file revision has been uploaded."); toastService.showMessage(t("file_properties.upload_success"));
this.refresh(); this.refresh();
} } else {
else { toastService.showError(t("file_properties.upload_failed"));
toastService.showError("Upload of a new file revision failed.");
} }
}); });
} }
@ -126,7 +126,7 @@ export default class FilePropertiesWidget extends NoteContextAwareWidget {
// open doesn't work for protected notes since it works through a browser which isn't in protected session // open doesn't work for protected notes since it works through a browser which isn't in protected session
this.$openButton.toggle(!note.isProtected); this.$openButton.toggle(!note.isProtected);
this.$downloadButton.toggle(!note.isProtected || protectedSessionHolder.isProtectedSessionAvailable()) this.$downloadButton.toggle(!note.isProtected || protectedSessionHolder.isProtectedSessionAvailable());
this.$uploadNewRevisionButton.toggle(!note.isProtected || protectedSessionHolder.isProtectedSessionAvailable()) this.$uploadNewRevisionButton.toggle(!note.isProtected || protectedSessionHolder.isProtectedSessionAvailable());
} }
} }

View File

@ -677,5 +677,17 @@
"no_edited_notes_found": "今天还没有编辑过的笔记...", "no_edited_notes_found": "今天还没有编辑过的笔记...",
"title": "编辑过的笔记", "title": "编辑过的笔记",
"deleted": "(已删除)" "deleted": "(已删除)"
},
"file_properties": {
"note_id": "笔记 ID",
"original_file_name": "原始文件名",
"file_type": "文件类型",
"file_size": "文件大小",
"download": "下载",
"open": "打开",
"upload_new_revision": "上传新修改",
"upload_success": "新文件修改已上传。",
"upload_failed": "新文件修改上传失败。",
"title": "文件"
} }
} }

View File

@ -678,5 +678,17 @@
"no_edited_notes_found": "No edited notes on this day yet ...", "no_edited_notes_found": "No edited notes on this day yet ...",
"title": "Edited Notes", "title": "Edited Notes",
"deleted": "(deleted)" "deleted": "(deleted)"
},
"file_properties": {
"note_id": "Note ID",
"original_file_name": "Original file name",
"file_type": "File type",
"file_size": "File size",
"download": "Download",
"open": "Open",
"upload_new_revision": "Upload new revision",
"upload_success": "New file revision has been uploaded.",
"upload_failed": "Upload of a new file revision failed.",
"title": "File"
} }
} }