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.
This commit is contained in:
Alan Guo Xiang Tan 2022-05-12 15:10:14 +08:00 committed by GitHub
parent 61eefcf037
commit 0bc04cb003
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 24 deletions

View File

@ -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 {

View File

@ -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}}
<span class="sidebar-section-link-content-badge">

View File

@ -4,12 +4,12 @@
{{d-icon this.headerCaretIcon}}
</button>
<LinkTo @route={{@headerRoute}} @query={{@headerQuery}} @class="sidebar-section-header-link">
{{@headerTitle}}
<LinkTo @route={{@headerRoute}} @query={{@headerQuery}} @class="sidebar-section-header-link" title={{@headerLinkTitle}}>
{{@headerLinkText}}
</LinkTo>
{{#if @headerAction}}
<button type="button" class="sidebar-section-header-button" {{on "click" @headerAction}}>
<button type="button" class="sidebar-section-header-button" {{on "click" @headerAction}} title={{@headerActionTitle}}>
{{d-icon @headerActionIcon}}
</button>
{{/if}}

View File

@ -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"}}>
<Sidebar::SectionLink
@linkName="everything"
@route={{this.everythingSectionLinkRoute}}
@query={{hash f=undefined}}
@title={{i18n "sidebar.sections.topics.links.everything.title"}}
@content={{i18n "sidebar.sections.topics.links.everything.content"}}
@current-when={{"discovery.latest discovery.new discovery.unread discovery.top"}}
@badgeText={{this.everythingSectionLinkBadgeText}} />
<Sidebar::SectionLink @linkName="tracked" @route="discovery.latest" @query={{hash f="tracked"}} />
<Sidebar::SectionLink @linkName="bookmarked" @route="userActivity.bookmarks" @model={{this.currentUser}} />
<Sidebar::SectionLink
@linkName="tracked"
@route="discovery.latest"
@query={{hash f="tracked"}}
@title={{i18n "sidebar.sections.topics.links.tracked.title"}}
@content={{i18n "sidebar.sections.topics.links.tracked.content"}} />
<Sidebar::SectionLink
@linkName="bookmarked"
@route="userActivity.bookmarks"
@model={{this.currentUser}}
@title={{i18n "sidebar.sections.topics.links.bookmarked.title"}}
@content={{i18n "sidebar.sections.topics.links.bookmarked.content"}} />
</Sidebar::Section>

View File

@ -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: