From b7809a709cf04d105ff14d2792270ec342c2757c Mon Sep 17 00:00:00 2001 From: Nriver <6752679+Nriver@users.noreply.github.com> Date: Tue, 6 Aug 2024 10:12:53 +0800 Subject: [PATCH] add translation for ribbon widgets: promoted_attributes.js --- .../widgets/ribbon_widgets/promoted_attributes.js | 15 ++++++++------- src/public/translations/cn/translation.json | 9 +++++++++ src/public/translations/en/translation.json | 9 +++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/public/app/widgets/ribbon_widgets/promoted_attributes.js b/src/public/app/widgets/ribbon_widgets/promoted_attributes.js index 9304b0b0f..ecbdf59b2 100644 --- a/src/public/app/widgets/ribbon_widgets/promoted_attributes.js +++ b/src/public/app/widgets/ribbon_widgets/promoted_attributes.js @@ -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 = $("") .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($("
") @@ -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 = $("") .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 = $("") .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"); diff --git a/src/public/translations/cn/translation.json b/src/public/translations/cn/translation.json index 70b249026..d0d398b12 100644 --- a/src/public/translations/cn/translation.json +++ b/src/public/translations/cn/translation.json @@ -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": "移除此属性" } } diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.json index a9371a0eb..3b9ae57f7 100644 --- a/src/public/translations/en/translation.json +++ b/src/public/translations/en/translation.json @@ -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" } }