refactor for more complete translation strings

This commit is contained in:
awesomerobot 2023-03-13 14:16:29 -04:00
parent 9970636563
commit 8d04a13daf
2 changed files with 37 additions and 30 deletions

View File

@ -16,6 +16,7 @@ import { inject as controller } from "@ember/controller";
import I18n from "I18n"; import I18n from "I18n";
import { isEmpty } from "@ember/utils"; import { isEmpty } from "@ember/utils";
import { registerTopicFooterDropdown } from "discourse/lib/register-topic-footer-dropdown"; import { registerTopicFooterDropdown } from "discourse/lib/register-topic-footer-dropdown";
import RawHtml from "discourse/widgets/raw-html";
const PLUGIN_ID = "discourse-assign"; const PLUGIN_ID = "discourse-assign";
@ -701,38 +702,39 @@ function initialize(api) {
]; ];
const assigneeElements = []; const assigneeElements = [];
const assignedHtml = (username, path) => {
return `<span>${htmlSafe(
I18n.t("discourse_assign.assigned_topic_to", {
username,
path,
})
)}</span>`;
};
if (assignedToUser) { if (assignedToUser) {
assigneeElements.push( assigneeElements.push(
h("span.assignee", [ h(
h("span", `${I18n.t("discourse_assign.topic_to")} `), "span.assignee",
h( new RawHtml({
"a", html: assignedHtml(
{ assignedToUser.username,
attributes: { assignedToUserPath(assignedToUser)
class: "assigned-to-username", ),
href: assignedToUserPath(assignedToUser), })
}, )
},
assignedToUser.username
),
])
); );
} }
if (assignedToGroup) { if (assignedToGroup) {
assigneeElements.push( assigneeElements.push(
h("span.assignee", [ h(
h("span", `${I18n.t("discourse_assign.topic_to")} `), "span.assignee",
h( new RawHtml({
"a", html: assignedHtml(
{ assignedToGroup.name,
attributes: { assignedToGroupPath(assignedToGroup)
class: "assigned-to-group", ),
href: assignedToGroupPath(assignedToGroup), })
}, )
},
assignedToGroup.name
),
])
); );
} }
if (indirectlyAssignedTo) { if (indirectlyAssignedTo) {
@ -749,7 +751,7 @@ function initialize(api) {
href: `${topic.url}/${postNumber}`, href: `${topic.url}/${postNumber}`,
}, },
}, },
I18n.t("discourse_assign.assign_post_to", { I18n.t("discourse_assign.assign_post_to_multiple", {
post_number: postNumber, post_number: postNumber,
username: assignee.username || assignee.name, username: assignee.username || assignee.name,
}) })
@ -761,7 +763,9 @@ function initialize(api) {
if (!isEmpty(assigneeElements)) { if (!isEmpty(assigneeElements)) {
return h("p.assigned-to", [ return h("p.assigned-to", [
assignedToUser ? iconNode("user-plus") : iconNode("group-plus"), assignedToUser ? iconNode("user-plus") : iconNode("group-plus"),
h("span.assign-text", I18n.t("discourse_assign.assigned")), assignedToUser || assignedToGroup
? ""
: h("span.assign-text", I18n.t("discourse_assign.assigned")),
assigneeElements, assigneeElements,
]); ]);
} }

View File

@ -27,8 +27,11 @@ en:
assigned: "Assigned" assigned: "Assigned"
group_everyone: "Everyone" group_everyone: "Everyone"
assigned_to: "Assigned to" assigned_to: "Assigned to"
topic_to: "topic to" # Context example: "Assigned [topic to] example_username" assigned_topic_to: "Assigned topic to <a href='%{path}'>%{username}</a>"
assign_post_to: "#%{post_number} to %{username}" # Context example: "Assigned [#2 to example_username]" assign_post_to: "Assigned #%{post_number} to %{username}"
assign_post_to_multiple:
"#%{post_number} to %{username}"
# assign_post_to_multiple used in list form, example: "Assigned topic to username0, [#2 to username1], [#10 to username2]"
assigned_to_w_ellipsis: "Assigned to..." assigned_to_w_ellipsis: "Assigned to..."
assign_notification: "<p><span>%{username}</span> %{description}</p>" assign_notification: "<p><span>%{username}</span> %{description}</p>"
assign_group_notification: "<p><span>%{username}</span> %{description}</p>" assign_group_notification: "<p><span>%{username}</span> %{description}</p>"