add translation for 8 type widgets

This commit is contained in:
Nriver 2024-08-07 11:18:02 +08:00
parent 40f74656f3
commit 2754bd7a93
10 changed files with 94 additions and 20 deletions

View File

@ -3,6 +3,7 @@ import AttachmentDetailWidget from "../attachment_detail.js";
import linkService from "../../services/link.js"; import linkService from "../../services/link.js";
import froca from "../../services/froca.js"; import froca from "../../services/froca.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="attachment-detail note-detail-printable"> <div class="attachment-detail note-detail-printable">
@ -47,15 +48,15 @@ export default class AttachmentDetailTypeWidget extends TypeWidget {
this.$wrapper.empty(); this.$wrapper.empty();
this.children = []; this.children = [];
const $helpButton = $('<button class="attachment-help-button" type="button" data-help-page="attachments" title="Open help page on attachments"><span class="bx bx-help-circle"></span></button>'); const $helpButton = $('<button class="attachment-help-button" type="button" data-help-page="attachments" title="' + t('attachment_detail.open_help_page') + '"><span class="bx bx-help-circle"></span></button>');
utils.initHelpButtons($helpButton); utils.initHelpButtons($helpButton);
this.$linksWrapper.empty().append( this.$linksWrapper.empty().append(
"Owning note: ", t('attachment_detail.owning_note'),
await linkService.createLink(this.noteId), await linkService.createLink(this.noteId),
", you can also open the ", t('attachment_detail.you_can_also_open'),
await linkService.createLink(this.noteId, { await linkService.createLink(this.noteId, {
title: 'List of all attachments', title: t('attachment_detail.list_of_all_attachments'),
viewScope: { viewScope: {
viewMode: 'attachments' viewMode: 'attachments'
} }
@ -66,8 +67,7 @@ export default class AttachmentDetailTypeWidget extends TypeWidget {
const attachment = await froca.getAttachment(this.attachmentId, true); const attachment = await froca.getAttachment(this.attachmentId, true);
if (!attachment) { if (!attachment) {
this.$wrapper.html("<strong>This attachment has been deleted.</strong>"); this.$wrapper.html("<strong>" + t('attachment_detail.attachment_deleted') + "</strong>");
return; return;
} }

View File

@ -2,6 +2,7 @@ import TypeWidget from "./type_widget.js";
import AttachmentDetailWidget from "../attachment_detail.js"; import AttachmentDetailWidget from "../attachment_detail.js";
import linkService from "../../services/link.js"; import linkService from "../../services/link.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="attachment-list note-detail-printable"> <div class="attachment-list note-detail-printable">
@ -39,19 +40,19 @@ export default class AttachmentListTypeWidget extends TypeWidget {
} }
async doRefresh(note) { async doRefresh(note) {
const $helpButton = $('<button class="attachment-help-button" type="button" data-help-page="attachments" title="Open help page on attachments"><span class="bx bx-help-circle"></span></button>'); const $helpButton = $('<button class="attachment-help-button" type="button" data-help-page="attachments" title="' + t('attachment_list.open_help_page') + '"><span class="bx bx-help-circle"></span></button>');
utils.initHelpButtons($helpButton); utils.initHelpButtons($helpButton);
const noteLink = await linkService.createLink(this.noteId); // do separately to avoid race condition between empty() and .append() const noteLink = await linkService.createLink(this.noteId); // do separately to avoid race condition between empty() and .append()
this.$linksWrapper.empty().append( this.$linksWrapper.empty().append(
$('<div>').append( $('<div>').append(
"Owning note: ", t('attachment_list.owning_note'),
noteLink, noteLink,
), ),
$('<div>').append( $('<div>').append(
$('<button class="btn btn-sm">') $('<button class="btn btn-sm">')
.text("Upload attachments") .text(t('attachment_list.upload_attachments'))
.on('click', () => this.triggerCommand("showUploadAttachmentsDialog", {noteId: this.noteId})), .on('click', () => this.triggerCommand("showUploadAttachmentsDialog", {noteId: this.noteId})),
$helpButton $helpButton
) )
@ -64,8 +65,7 @@ export default class AttachmentListTypeWidget extends TypeWidget {
const attachments = await note.getAttachments(); const attachments = await note.getAttachments();
if (attachments.length === 0) { if (attachments.length === 0) {
this.$list.html('<div class="alert alert-info">This note has no attachments.</div>'); this.$list.html('<div class="alert alert-info">' + t('attachment_list.no_attachments') + '</div>');
return; return;
} }

View File

@ -1,4 +1,5 @@
import TypeWidget from "./type_widget.js"; import TypeWidget from "./type_widget.js";
import { t } from "../../services/i18n.js";
const TPL = ` const TPL = `
<div class="note-detail-book note-detail-printable"> <div class="note-detail-book note-detail-printable">
@ -13,7 +14,7 @@ const TPL = `
</style> </style>
<div class="note-detail-book-empty-help alert alert-warning" style="margin: 50px; padding: 20px;"> <div class="note-detail-book-empty-help alert alert-warning" style="margin: 50px; padding: 20px;">
This note of type Book doesn't have any child notes so there's nothing to display. See <a href="https://github.com/zadam/trilium/wiki/Book-note">wiki</a> for details. ${t('book.no_children_help')}
</div> </div>
</div>`; </div>`;

View File

@ -1,3 +1,4 @@
import { t } from "../../services/i18n.js";
import libraryLoader from "../../services/library_loader.js"; import libraryLoader from "../../services/library_loader.js";
import TypeWidget from "./type_widget.js"; import TypeWidget from "./type_widget.js";
import keyboardActionService from "../../services/keyboard_actions.js"; import keyboardActionService from "../../services/keyboard_actions.js";
@ -62,7 +63,7 @@ export default class EditableCodeTypeWidget extends TypeWidget {
// all the way to the bottom of the note. With line wrap, there's no horizontal scrollbar so no problem // all the way to the bottom of the note. With line wrap, there's no horizontal scrollbar so no problem
lineWrapping: options.is('codeLineWrapEnabled'), lineWrapping: options.is('codeLineWrapEnabled'),
dragDrop: false, // with true the editor inlines dropped files which is not what we expect dragDrop: false, // with true the editor inlines dropped files which is not what we expect
placeholder: "Type the content of your code note here...", placeholder: t('editable_code.placeholder'),
}); });
this.codeEditor.on('change', () => this.spacedUpdate.scheduleUpdate()); this.codeEditor.on('change', () => this.spacedUpdate.scheduleUpdate());

View File

@ -1,3 +1,4 @@
import { t } from "../../services/i18n.js";
import libraryLoader from "../../services/library_loader.js"; import libraryLoader from "../../services/library_loader.js";
import noteAutocompleteService from '../../services/note_autocomplete.js'; import noteAutocompleteService from '../../services/note_autocomplete.js';
import mimeTypesService from '../../services/mime_types.js'; import mimeTypesService from '../../services/mime_types.js';
@ -167,7 +168,7 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
}); });
await this.watchdog.create(this.$editor[0], { await this.watchdog.create(this.$editor[0], {
placeholder: "Type the content of your note here ...", placeholder: t('editable_text.placeholder'),
mention: mentionSetup, mention: mentionSetup,
codeBlock: { codeBlock: {
languages: codeBlockLanguages languages: codeBlockLanguages

View File

@ -2,6 +2,7 @@ import noteAutocompleteService from '../../services/note_autocomplete.js';
import TypeWidget from "./type_widget.js"; import TypeWidget from "./type_widget.js";
import appContext from "../../components/app_context.js"; import appContext from "../../components/app_context.js";
import searchService from "../../services/search.js"; import searchService from "../../services/search.js";
import { t } from "../../services/i18n.js";
const TPL = ` const TPL = `
<div class="note-detail-empty note-detail-printable"> <div class="note-detail-empty note-detail-printable">
@ -33,9 +34,9 @@ const TPL = `
</style> </style>
<div class="form-group"> <div class="form-group">
<label>Open a note by typing the note's title into the input below or choose a note in the tree.</label> <label>${t('empty.open_note_instruction')}</label>
<div class="input-group"> <div class="input-group">
<input class="form-control note-autocomplete" placeholder="search for a note by its name"> <input class="form-control note-autocomplete" placeholder="${t('empty.search_placeholder')}">
</div> </div>
</div> </div>
@ -78,7 +79,7 @@ export default class EmptyTypeWidget extends TypeWidget {
$('<div class="workspace-note">') $('<div class="workspace-note">')
.append($("<div>").addClass(`${workspaceNote.getIcon()} workspace-icon`)) .append($("<div>").addClass(`${workspaceNote.getIcon()} workspace-icon`))
.append($("<div>").text(workspaceNote.title)) .append($("<div>").text(workspaceNote.title))
.attr("title", `Enter workspace ${workspaceNote.title}`) .attr("title", t('empty.enter_workspace', { title: workspaceNote.title }))
.on('click', () => this.triggerCommand('hoistNote', {noteId: workspaceNote.noteId})) .on('click', () => this.triggerCommand('hoistNote', {noteId: workspaceNote.noteId}))
); );
} }

View File

@ -1,5 +1,6 @@
import openService from "../../services/open.js"; import openService from "../../services/open.js";
import TypeWidget from "./type_widget.js"; import TypeWidget from "./type_widget.js";
import { t } from "../../services/i18n.js";
const TPL = ` const TPL = `
<div class="note-detail-file note-detail-printable"> <div class="note-detail-file note-detail-printable">
@ -25,7 +26,7 @@ const TPL = `
<pre class="file-preview-content"></pre> <pre class="file-preview-content"></pre>
<div class="file-preview-not-available alert alert-info"> <div class="file-preview-not-available alert alert-info">
File preview is not available for this file format. ${t('file.file_preview_not_available')}
</div> </div>
<iframe class="pdf-preview" style="width: 100%; height: 100%; flex-grow: 100;"></iframe> <iframe class="pdf-preview" style="width: 100%; height: 100%; flex-grow: 100;"></iframe>

View File

@ -1,5 +1,6 @@
import protectedSessionService from '../../services/protected_session.js'; import protectedSessionService from '../../services/protected_session.js';
import TypeWidget from "./type_widget.js"; import TypeWidget from "./type_widget.js";
import { t } from "../../services/i18n.js";
const TPL = ` const TPL = `
<div class="protected-session-password-component note-detail-printable"> <div class="protected-session-password-component note-detail-printable">
@ -12,11 +13,11 @@ const TPL = `
<form class="protected-session-password-form"> <form class="protected-session-password-form">
<div class="form-group"> <div class="form-group">
<label for="protected-session-password-in-detail">Showing protected note requires entering your password:</label> <label for="protected-session-password-in-detail">${t('protected_session.enter_password_instruction')}</label>
<input class="protected-session-password-in-detail form-control protected-session-password" type="password"> <input class="protected-session-password-in-detail form-control protected-session-password" type="password">
</div> </div>
<button class="btn btn-primary">Start protected session <kbd>enter</kbd></button> <button class="btn btn-primary">${t('protected_session.start_session_button')} <kbd>enter</kbd></button>
</form> </form>
</div>`; </div>`;

View File

@ -853,5 +853,39 @@
"label_year_comparison": "数字比较(也包括>>=<)。", "label_year_comparison": "数字比较(也包括>>=<)。",
"label_date_created": "上个月创建的笔记", "label_date_created": "上个月创建的笔记",
"error": "搜索错误:{{error}}" "error": "搜索错误:{{error}}"
},
"attachment_detail": {
"open_help_page": "打开附件帮助页面",
"owning_note": "所属笔记: ",
"you_can_also_open": ",你还可以打开",
"list_of_all_attachments": "所有附件列表",
"attachment_deleted": "该附件已被删除。"
},
"attachment_list": {
"open_help_page": "打开附件帮助页面",
"owning_note": "所属笔记: ",
"upload_attachments": "上传附件",
"no_attachments": "此笔记没有附件。"
},
"book": {
"no_children_help": "此类型为书籍的笔记没有任何子笔记,因此没有内容显示。请参阅 <a href=\"https://github.com/zadam/trilium/wiki/Book-note\">wiki</a> 了解详情"
},
"editable_code": {
"placeholder": "在这里输入您的代码笔记内容..."
},
"editable_text": {
"placeholder": "在这里输入您的笔记内容..."
},
"empty": {
"open_note_instruction": "通过在下面的输入框中输入笔记标题或在树中选择笔记来打开笔记。",
"search_placeholder": "按名称搜索笔记",
"enter_workspace": "进入工作区 {{title}}"
},
"file": {
"file_preview_not_available": "此文件格式不支持预览。"
},
"protected_session": {
"enter_password_instruction": "显示受保护的笔记需要输入您的密码:",
"start_session_button": "开始受保护的会话"
} }
} }

View File

@ -854,5 +854,39 @@
"label_year_comparison": "numerical comparison (also >, >=, <).", "label_year_comparison": "numerical comparison (also >, >=, <).",
"label_date_created": "notes created in the last month", "label_date_created": "notes created in the last month",
"error": "Search error: {{error}}" "error": "Search error: {{error}}"
},
"attachment_detail": {
"open_help_page": "Open help page on attachments",
"owning_note": "Owning note: ",
"you_can_also_open": ", you can also open the ",
"list_of_all_attachments": "List of all attachments",
"attachment_deleted": "This attachment has been deleted."
},
"attachment_list": {
"open_help_page": "Open help page on attachments",
"owning_note": "Owning note: ",
"upload_attachments": "Upload attachments",
"no_attachments": "This note has no attachments."
},
"book": {
"no_children_help": "This note of type Book doesn't have any child notes so there's nothing to display. See <a href=\"https://github.com/zadam/trilium/wiki/Book-note\">wiki</a> for details."
},
"editable_code": {
"placeholder": "Type the content of your code note here..."
},
"editable_text": {
"placeholder": "Type the content of your note here ..."
},
"empty": {
"open_note_instruction": "Open a note by typing the note's title into the input below or choose a note in the tree.",
"search_placeholder": "search for a note by its name",
"enter_workspace": "Enter workspace {{title}}"
},
"file": {
"file_preview_not_available": "File preview is not available for this file format."
},
"protected_session": {
"enter_password_instruction": "Showing protected note requires entering your password:",
"start_session_button": "Start protected session"
} }
} }