add translation for the rest 7 dialogs

This commit is contained in:
Nriver
2024-07-25 17:14:08 +08:00
parent a8d6e5b1ea
commit da96344690
9 changed files with 218 additions and 87 deletions

View File

@@ -1,3 +1,4 @@
import { t } from "../../services/i18n.js";
import utils from '../../services/utils.js';
import server from '../../services/server.js';
import toastService from "../../services/toast.js";
@@ -39,13 +40,13 @@ const TPL = `
<div class="modal-dialog modal-xl" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title mr-auto">Note revisions</h5>
<h5 class="modal-title mr-auto">${t("revisions.note_revisions")}</h5>
<button class="revisions-erase-all-revisions-button btn btn-sm"
title="Delete all revisions of this note"
style="padding: 0 10px 0 10px;" type="button">Delete all revisions</button>
title="${t("revisions.delete_all_revisions")}"
style="padding: 0 10px 0 10px;" type="button">${t("revisions.delete_all_button")}</button>
<button class="help-button" type="button" data-help-page="Note-revisions" title="Help on Note revisions">?</button>
<button class="help-button" type="button" data-help-page="Note-revisions" title="${t("revisions.help_title")}">?</button>
<button type="button" class="close" data-dismiss="modal" aria-label="Close" style="margin-left: 0 !important;">
<span aria-hidden="true">&times;</span>
@@ -53,7 +54,7 @@ const TPL = `
</div>
<div class="modal-body" style="display: flex; height: 80vh;">
<div class="dropdown">
<button class="revision-list-dropdown" type="button" style="display: none;" data-toggle="dropdown">Dropdown trigger</button>
<button class="revision-list-dropdown" type="button" style="display: none;" data-toggle="dropdown">${t("revisions.dropdown_trigger")}</button>
<div class="revision-list dropdown-menu" style="position: static; height: 100%; overflow: auto;"></div>
</div>
@@ -105,14 +106,14 @@ export default class RevisionsDialog extends BasicWidget {
});
this.$eraseAllRevisionsButton.on('click', async () => {
const text = 'Do you want to delete all revisions of this note? This action will erase revision title and content, but still preserve revision metadata.';
const text = t("revisions.confirm_delete_all");
if (await dialogService.confirm(text)) {
await server.remove(`notes/${this.note.noteId}/revisions`);
this.$widget.modal('hide');
toastService.showMessage('Note revisions has been deleted.');
toastService.showMessage(t("revisions.revisions_deleted"));
}
});
@@ -149,7 +150,7 @@ export default class RevisionsDialog extends BasicWidget {
$('<a class="dropdown-item" tabindex="0">')
.text(`${item.dateLastEdited.substr(0, 16)} (${utils.formatSize(item.contentLength)})`)
.attr('data-revision-id', item.revisionId)
.attr('title', `This revision was last edited on ${item.dateLastEdited}`)
.attr('title', t("revisions.revision_last_edited", { date: item.dateLastEdited }))
);
}
@@ -160,7 +161,7 @@ export default class RevisionsDialog extends BasicWidget {
this.revisionId = this.revisionItems[0].revisionId;
}
} else {
this.$title.text("No revisions for this note yet...");
this.$title.text(t("revisions.no_revisions"));
this.revisionId = null;
}
@@ -182,31 +183,31 @@ export default class RevisionsDialog extends BasicWidget {
renderContentButtons(revisionItem) {
this.$titleButtons.empty();
const $restoreRevisionButton = $('<button class="btn btn-sm" type="button">Restore this revision</button>');
const $restoreRevisionButton = $(`<button class="btn btn-sm" type="button">${t("revisions.restore_button")}</button>`);
$restoreRevisionButton.on('click', async () => {
const text = 'Do you want to restore this revision? This will overwrite current title/content of the note with this revision.';
const text = t("revisions.confirm_restore");
if (await dialogService.confirm(text)) {
await server.post(`revisions/${revisionItem.revisionId}/restore`);
this.$widget.modal('hide');
toastService.showMessage('Note revision has been restored.');
toastService.showMessage(t("revisions.revision_restored"));
}
});
const $eraseRevisionButton = $('<button class="btn btn-sm" type="button">Delete this revision</button>');
const $eraseRevisionButton = $(`<button class="btn btn-sm" type="button">${t("revisions.delete_button")}</button>`);
$eraseRevisionButton.on('click', async () => {
const text = 'Do you want to delete this revision? This action will delete revision title and content, but still preserve revision metadata.';
const text = t("revisions.confirm_delete");
if (await dialogService.confirm(text)) {
await server.remove(`revisions/${revisionItem.revisionId}`);
this.loadRevisions(revisionItem.noteId);
toastService.showMessage('Note revision has been deleted.');
toastService.showMessage(t("revisions.revision_deleted"));
}
});
@@ -220,7 +221,7 @@ export default class RevisionsDialog extends BasicWidget {
.append($eraseRevisionButton)
.append(' &nbsp; ');
const $downloadButton = $('<button class="btn btn-sm btn-primary" type="button">Download</button>');
const $downloadButton = $(`<button class="btn btn-sm btn-primary" type="button">${t("revisions.download_button")}</button>`);
$downloadButton.on('click', () => openService.downloadRevision(revisionItem.noteId, revisionItem.revisionId));
@@ -254,18 +255,18 @@ export default class RevisionsDialog extends BasicWidget {
} else if (revisionItem.type === 'file') {
const $table = $("<table cellpadding='10'>")
.append($("<tr>").append(
$("<th>").text("MIME: "),
$("<th>").text(t("revisions.mime")),
$("<td>").text(revisionItem.mime)
))
.append($("<tr>").append(
$("<th>").text("File size:"),
$("<th>").text(t("revisions.file_size")),
$("<td>").text(utils.formatSize(revisionItem.contentLength))
));
if (fullRevision.content) {
$table.append($("<tr>").append(
$('<td colspan="2">').append(
$('<div style="font-weight: bold;">').text("Preview:"),
$('<div style="font-weight: bold;">').text(t("revisions.preview")),
$('<pre class="file-preview-content"></pre>')
.text(fullRevision.content)
)
@@ -288,7 +289,7 @@ export default class RevisionsDialog extends BasicWidget {
this.$content.append($("<pre>").text(fullRevision.content));
} else {
this.$content.text("Preview isn't available for this note type.");
this.$content.text(t("revisions.preview_not_available"));
}
}
}