add translation for ribbon widgets: book_properties.js

This commit is contained in:
Nriver 2024-08-05 10:23:38 +08:00
parent 97e127a4af
commit d47a5c4ffe
3 changed files with 33 additions and 9 deletions

View File

@ -1,5 +1,6 @@
import NoteContextAwareWidget from "../note_context_aware_widget.js";
import attributeService from "../../services/attributes.js";
import { t } from "../../services/i18n.js";
const TPL = `
<div class="book-properties-widget">
@ -15,32 +16,33 @@ const TPL = `
</style>
<div style="display: flex; align-items: baseline">
<span style="white-space: nowrap">View type:&nbsp; &nbsp;</span>
<span style="white-space: nowrap">${t("book_properties.view_type")}:&nbsp; &nbsp;</span>
<select class="view-type-select form-control form-control-sm">
<option value="grid">Grid</option>
<option value="list">List</option>
<option value="grid">${t("book_properties.grid")}</option>
<option value="list">${t("book_properties.list")}</option>
</select>
</div>
<button type="button"
class="collapse-all-button btn btn-sm"
title="Collapse all notes">
title="${t("book_properties.collapse_all_notes")}">
<span class="bx bx-layer-minus"></span>
Collapse
${t("book_properties.collapse")}
</button>
<button type="button"
class="expand-children-button btn btn-sm"
title="Expand all children">
title="${t("book_properties.expand_all_children")}">
<span class="bx bx-move-vertical"></span>
Expand
${t("book_properties.expand")}
</button>
</div>
`;
export default class BookPropertiesWidget extends NoteContextAwareWidget {
get name() {
return "bookProperties";
@ -58,7 +60,7 @@ export default class BookPropertiesWidget extends NoteContextAwareWidget {
return {
show: this.isEnabled(),
activate: true,
title: 'Book Properties',
title: t("book_properties.book_properties"),
icon: 'bx bx-book'
};
}
@ -101,7 +103,7 @@ export default class BookPropertiesWidget extends NoteContextAwareWidget {
async toggleViewType(type) {
if (type !== 'list' && type !== 'grid') {
throw new Error(`Invalid view type '${type}'`);
throw new Error(t("book_properties.invalid_view_type", { type }));
}
await attributeService.setLabel(this.noteId, 'viewType', type);

View File

@ -661,5 +661,16 @@
"note_type": "笔记类型",
"editable": "可编辑",
"basic_properties": "基本属性"
},
"book_properties": {
"view_type": "视图类型",
"grid": "网格",
"list": "列表",
"collapse_all_notes": "折叠所有笔记",
"expand_all_children": "展开所有子项",
"collapse": "折叠",
"expand": "展开",
"book_properties": "书籍属性",
"invalid_view_type": "无效的查看类型 '{{type}}'"
}
}

View File

@ -662,5 +662,16 @@
"note_type": "Note type",
"editable": "Editable",
"basic_properties": "Basic Properties"
},
"book_properties": {
"view_type": "View type",
"grid": "Grid",
"list": "List",
"collapse_all_notes": "Collapse all notes",
"expand_all_children": "Expand all children",
"collapse": "Collapse",
"expand": "Expand",
"book_properties": "Book Properties",
"invalid_view_type": "Invalid view type '{{type}}'"
}
}