From 0bc04cb003cae5cf5342a47f034256e05df1ef39 Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Thu, 12 May 2022 15:10:14 +0800 Subject: [PATCH] DEV: Add missing titles on sidebar buttons. (#16730) * Also small refactor to reduce magical generation of translation string key when using `Section` and `SectionLink` components. --- .../app/components/sidebar/topics-section.js | 4 +-- .../components/sidebar/section-link.hbs | 4 +-- .../templates/components/sidebar/section.hbs | 6 ++-- .../components/sidebar/topics-section.hbs | 23 ++++++++++++--- config/locales/client.en.yml | 29 ++++++++++--------- 5 files changed, 42 insertions(+), 24 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/sidebar/topics-section.js b/app/assets/javascripts/discourse/app/components/sidebar/topics-section.js index 6d65e9d1eb..e68fd2dafa 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/topics-section.js +++ b/app/assets/javascripts/discourse/app/components/sidebar/topics-section.js @@ -47,11 +47,11 @@ export default class SidebarTopicsSection extends GlimmerComponent { get everythingSectionLinkBadgeText() { if (this.totalUnread > 0) { - return I18n.t("sidebar.sections.links.badge.unread_count", { + return I18n.t("sidebar.unread_count", { count: this.totalUnread, }); } else if (this.totalNew > 0) { - return I18n.t("sidebar.sections.links.badge.new_count", { + return I18n.t("sidebar.new_count", { count: this.totalNew, }); } else { diff --git a/app/assets/javascripts/discourse/app/templates/components/sidebar/section-link.hbs b/app/assets/javascripts/discourse/app/templates/components/sidebar/section-link.hbs index 19013d7349..70750f06ee 100644 --- a/app/assets/javascripts/discourse/app/templates/components/sidebar/section-link.hbs +++ b/app/assets/javascripts/discourse/app/templates/components/sidebar/section-link.hbs @@ -5,9 +5,9 @@ @query={{@query}} @models={{if @model (array @model) (if @models @models (array))}} @current-when={{@current-when}} - @title={{i18n (concat "sidebar.sections.links." @linkName ".title")}} + @title={{@title}} > - {{i18n (concat "sidebar.sections.links." @linkName ".content")}} + {{@content}} {{#if @badgeText}} diff --git a/app/assets/javascripts/discourse/app/templates/components/sidebar/section.hbs b/app/assets/javascripts/discourse/app/templates/components/sidebar/section.hbs index 91af8a1df5..3667ba75a0 100644 --- a/app/assets/javascripts/discourse/app/templates/components/sidebar/section.hbs +++ b/app/assets/javascripts/discourse/app/templates/components/sidebar/section.hbs @@ -4,12 +4,12 @@ {{d-icon this.headerCaretIcon}} - - {{@headerTitle}} + + {{@headerLinkText}} {{#if @headerAction}} - {{/if}} diff --git a/app/assets/javascripts/discourse/app/templates/components/sidebar/topics-section.hbs b/app/assets/javascripts/discourse/app/templates/components/sidebar/topics-section.hbs index 844df86443..7d394723c5 100644 --- a/app/assets/javascripts/discourse/app/templates/components/sidebar/topics-section.hbs +++ b/app/assets/javascripts/discourse/app/templates/components/sidebar/topics-section.hbs @@ -2,17 +2,32 @@ @sectionName="topics" @headerRoute="discovery.latest" @headerQuery={{hash f=undefined}} - @headerTitle="topics" + @headerLinkText={{i18n "sidebar.sections.topics.header_link_text"}} + @headerLinkTitle={{i18n "sidebar.sections.topics.header_link_title"}} @headerActionIcon="plus" - @headerAction={{this.composeTopic}}> + @headerAction={{this.composeTopic}} + @headerActionTitle={{i18n "sidebar.sections.topics.header_action_title"}}> - - + + + diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index b9785d11b3..bfdca47c80 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -4032,20 +4032,23 @@ en: redirect_after_success: "Second factor authentication is successful. Redirecting to the previous page…" sidebar: + unread_count: "%{count} unread" + new_count: "%{count} new" sections: - links: - badge: - unread_count: "%{count} unread" - new_count: "%{count} new" - everything: - content: "Everything" - title: "All topics" - tracked: - content: "Tracked" - title: "All tracked topics" - bookmarked: - content: "Bookmarked" - title: "All bookmarked topics" + topics: + header_link_title: "home" + header_link_text: "Topics" + header_action_title: "create a new topic" + links: + everything: + content: "Everything" + title: "All topics" + tracked: + content: "Tracked" + title: "All tracked topics" + bookmarked: + content: "Bookmarked" + title: "All bookmarked topics" # This section is exported to the javascript for i18n in the admin section admin_js: