add translation for ribbon widgets: promoted_attributes.js

This commit is contained in:
Nriver 2024-08-06 10:12:53 +08:00
parent 2916182cdf
commit b7809a709c
3 changed files with 26 additions and 7 deletions

View File

@ -1,3 +1,4 @@
import { t } from "../../services/i18n.js";
import server from "../../services/server.js";
import ws from "../../services/ws.js";
import treeService from "../../services/tree.js";
@ -76,7 +77,7 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
return {
show: true,
activate: options.is('promotedAttributesOpenInRibbon'),
title: "Promoted Attributes",
title: t('promoted_attributes.promoted_attributes'),
icon: "bx bx-table"
};
}
@ -221,11 +222,11 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
$input.prop('type', 'datetime-local')
}
else if (definition.labelType === 'url') {
$input.prop("placeholder", "http://website...");
$input.prop("placeholder", t("promoted_attributes.url_placeholder"));
const $openButton = $("<span>")
.addClass("input-group-text open-external-link-button bx bx-window-open")
.prop("title", "Open external link")
.prop("title", t("promoted_attributes.open_external_link"))
.on('click', () => window.open($input.val(), '_blank'));
$input.after($("<div>")
@ -233,7 +234,7 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
.append($openButton));
}
else {
ws.logError(`Unknown labelType '${definitionAttr.labelType}'`);
ws.logError(t("promoted_attributes.unknown_label_type", { type: definitionAttr.labelType }));
}
}
else if (valueAttr.type === 'relation') {
@ -256,14 +257,14 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
}
}
else {
ws.logError(`Unknown attribute type '${valueAttr.type}'`);
ws.logError(t(`promoted_attributes.unknown_attribute_type`, {type: valueAttr.type}));
return;
}
if (definition.multiplicity === "multi") {
const $addButton = $("<span>")
.addClass("bx bx-plus pointer")
.prop("title", "Add new attribute")
.prop("title", t("promoted_attributes.add_new_attribute"))
.on('click', async () => {
const $new = await this.createPromotedAttributeCell(definitionAttr, {
attributeId: "",
@ -279,7 +280,7 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
const $removeButton = $("<span>")
.addClass("bx bx-trash pointer")
.prop("title", "Remove this attribute")
.prop("title", t("promoted_attributes.remove_this_attribute"))
.on('click', async () => {
const attributeId = $input.attr("data-attribute-id");

View File

@ -737,5 +737,14 @@
},
"owned_attribute_list": {
"owned_attributes": "拥有的属性"
},
"promoted_attributes": {
"promoted_attributes": "升级属性",
"url_placeholder": "http://网站链接...",
"open_external_link": "打开外部链接",
"unknown_label_type": "未知的标签类型 '{{type}}'",
"unknown_attribute_type": "未知的属性类型 '{{type}}'",
"add_new_attribute": "添加新属性",
"remove_this_attribute": "移除此属性"
}
}

View File

@ -738,5 +738,14 @@
},
"owned_attribute_list": {
"owned_attributes": "Owned Attributes"
},
"promoted_attributes": {
"promoted_attributes": "Promoted Attributes",
"url_placeholder": "http://website...",
"open_external_link": "Open external link",
"unknown_label_type": "Unknown labelType '{{type}}'",
"unknown_attribute_type": "Unknown attribute type '{{type}}'",
"add_new_attribute": "Add new attribute",
"remove_this_attribute": "Remove this attribute"
}
}