mirror of
https://github.com/zadam/trilium.git
synced 2025-11-06 05:15:59 +01:00
add translation for buttons: attachments actions
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { t } from "../../services/i18n.js";
|
||||
import BasicWidget from "../basic_widget.js";
|
||||
import server from "../../services/server.js";
|
||||
import dialogService from "../../services/dialog.js";
|
||||
@@ -32,15 +33,15 @@ const TPL = `
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a data-trigger-command="openAttachment" class="dropdown-item"
|
||||
title="File will be open in an external application and watched for changes. You'll then be able to upload the modified version back to Trilium.">Open externally</a>
|
||||
title="${t('attachments_actions.open_externally_title')}">${t('attachments_actions.open_externally')}</a>
|
||||
<a data-trigger-command="openAttachmentCustom" class="dropdown-item"
|
||||
title="File will be open in an external application and watched for changes. You'll then be able to upload the modified version back to Trilium.">Open custom</a>
|
||||
<a data-trigger-command="downloadAttachment" class="dropdown-item">Download</a>
|
||||
<a data-trigger-command="renameAttachment" class="dropdown-item">Rename attachment</a>
|
||||
<a data-trigger-command="uploadNewAttachmentRevision" class="dropdown-item">Upload new revision</a>
|
||||
<a data-trigger-command="copyAttachmentLinkToClipboard" class="dropdown-item">Copy link to clipboard</a>
|
||||
<a data-trigger-command="convertAttachmentIntoNote" class="dropdown-item">Convert attachment into note</a>
|
||||
<a data-trigger-command="deleteAttachment" class="dropdown-item">Delete attachment</a>
|
||||
title="${t('attachments_actions.open_custom_title')}">${t('attachments_actions.open_custom')}</a>
|
||||
<a data-trigger-command="downloadAttachment" class="dropdown-item">${t('attachments_actions.download')}</a>
|
||||
<a data-trigger-command="renameAttachment" class="dropdown-item">${t('attachments_actions.rename_attachment')}</a>
|
||||
<a data-trigger-command="uploadNewAttachmentRevision" class="dropdown-item">${t('attachments_actions.upload_new_revision')}</a>
|
||||
<a data-trigger-command="copyAttachmentLinkToClipboard" class="dropdown-item">${t('attachments_actions.copy_link_to_clipboard')}</a>
|
||||
<a data-trigger-command="convertAttachmentIntoNote" class="dropdown-item">${t('attachments_actions.convert_attachment_into_note')}</a>
|
||||
<a data-trigger-command="deleteAttachment" class="dropdown-item">${t('attachments_actions.delete_attachment')}</a>
|
||||
</div>
|
||||
|
||||
<input type="file" class="attachment-upload-new-revision-input" style="display: none">
|
||||
@@ -70,26 +71,24 @@ export default class AttachmentActionsWidget extends BasicWidget {
|
||||
const result = await server.upload(`attachments/${this.attachmentId}/file`, fileToUpload);
|
||||
|
||||
if (result.uploaded) {
|
||||
toastService.showMessage("New attachment revision has been uploaded.");
|
||||
toastService.showMessage(t('attachments_actions.upload_success'));
|
||||
} else {
|
||||
toastService.showError("Upload of a new attachment revision failed.");
|
||||
toastService.showError(t('attachments_actions.upload_failed'));
|
||||
}
|
||||
});
|
||||
|
||||
if (!this.isFullDetail) {
|
||||
// we deactivate this button because the WatchedFileUpdateStatusWidget assumes only one visible attachment
|
||||
// in a note context, so it doesn't work in a list
|
||||
const $openAttachmentButton = this.$widget.find("[data-trigger-command='openAttachment']");
|
||||
$openAttachmentButton
|
||||
.addClass("disabled")
|
||||
.append($('<span class="disabled-tooltip"> (?)</span>')
|
||||
.attr("title", "Opening attachment externally is available only from the detail page, please first click on the attachment detail first and repeat the action.")
|
||||
.attr("title", t('attachments_actions.open_externally_detail_page'))
|
||||
);
|
||||
const $openAttachmentCustomButton = this.$widget.find("[data-trigger-command='openAttachmentCustom']");
|
||||
$openAttachmentCustomButton
|
||||
.addClass("disabled")
|
||||
.append($('<span class="disabled-tooltip"> (?)</span>')
|
||||
.attr("title", "Opening attachment externally is available only from the detail page, please first click on the attachment detail first and repeat the action.")
|
||||
.attr("title", t('attachments_actions.open_externally_detail_page'))
|
||||
);
|
||||
}
|
||||
if (!utils.isElectron()){
|
||||
@@ -97,7 +96,7 @@ export default class AttachmentActionsWidget extends BasicWidget {
|
||||
$openAttachmentCustomButton
|
||||
.addClass("disabled")
|
||||
.append($('<span class="disabled-tooltip"> (?)</span>')
|
||||
.attr("title", "Custom opening of attachments can only be done from the client.")
|
||||
.attr("title", t('attachments_actions.open_custom_client_only'))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -123,29 +122,29 @@ export default class AttachmentActionsWidget extends BasicWidget {
|
||||
}
|
||||
|
||||
async deleteAttachmentCommand() {
|
||||
if (!await dialogService.confirm(`Are you sure you want to delete attachment '${this.attachment.title}'?`)) {
|
||||
if (!await dialogService.confirm(t('attachments_actions.delete_confirm', { title: this.attachment.title }))) {
|
||||
return;
|
||||
}
|
||||
|
||||
await server.remove(`attachments/${this.attachmentId}`);
|
||||
toastService.showMessage(`Attachment '${this.attachment.title}' has been deleted.`);
|
||||
toastService.showMessage(t('attachments_actions.delete_success', { title: this.attachment.title }));
|
||||
}
|
||||
|
||||
async convertAttachmentIntoNoteCommand() {
|
||||
if (!await dialogService.confirm(`Are you sure you want to convert attachment '${this.attachment.title}' into a separate note?`)) {
|
||||
if (!await dialogService.confirm(t('attachments_actions.convert_confirm', { title: this.attachment.title }))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const {note: newNote} = await server.post(`attachments/${this.attachmentId}/convert-to-note`)
|
||||
toastService.showMessage(`Attachment '${this.attachment.title}' has been converted to note.`);
|
||||
toastService.showMessage(t('attachments_actions.convert_success', { title: this.attachment.title }));
|
||||
await ws.waitForMaxKnownEntityChangeId();
|
||||
await appContext.tabManager.getActiveContext().setNote(newNote.noteId);
|
||||
}
|
||||
|
||||
async renameAttachmentCommand() {
|
||||
const attachmentTitle = await dialogService.prompt({
|
||||
title: "Rename attachment",
|
||||
message: "Please enter new attachment's name",
|
||||
title: t('attachments_actions.rename_attachment'),
|
||||
message: t('attachments_actions.enter_new_name'),
|
||||
defaultValue: this.attachment.title
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user