From 8837ee4b39cb869fd65d3dfbc32a65dde86f799f Mon Sep 17 00:00:00 2001 From: Krzysztof Kotlarek Date: Mon, 19 Jun 2023 17:51:33 +1000 Subject: [PATCH] FIX: small bug with topics and my posts translations (#22179) 1. `everything` was changed to `topics` 2. Path for my posts translation is `sidebar.sections.community.links.my_posts.content` not `sidebar.sections.community.links.my/posts.content` --- .../everything-section-link.js | 2 +- .../my-posts-section-link.js | 2 +- spec/system/viewing_sidebar_spec.rb | 28 +++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/common/community-section/everything-section-link.js b/app/assets/javascripts/discourse/app/lib/sidebar/common/community-section/everything-section-link.js index 9f1c6c5bc1e..c541ad9b0c7 100644 --- a/app/assets/javascripts/discourse/app/lib/sidebar/common/community-section/everything-section-link.js +++ b/app/assets/javascripts/discourse/app/lib/sidebar/common/community-section/everything-section-link.js @@ -40,7 +40,7 @@ export default class EverythingSectionLink extends BaseSectionLink { } get title() { - return I18n.t("sidebar.sections.community.links.everything.title"); + return I18n.t("sidebar.sections.community.links.topics.title"); } get text() { diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/my-posts-section-link.js b/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/my-posts-section-link.js index be002344739..cc3b9988ed1 100644 --- a/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/my-posts-section-link.js +++ b/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/my-posts-section-link.js @@ -74,7 +74,7 @@ export default class MyPostsSectionLink extends BaseSectionLink { return I18n.t( `sidebar.sections.community.links.${this.overridenName .toLowerCase() - .replace(" ", "/")}.content`, + .replace(" ", "_")}.content`, { defaultValue: this.overridenName } ); } diff --git a/spec/system/viewing_sidebar_spec.rb b/spec/system/viewing_sidebar_spec.rb index 41044d40038..9ad545d38c0 100644 --- a/spec/system/viewing_sidebar_spec.rb +++ b/spec/system/viewing_sidebar_spec.rb @@ -89,4 +89,32 @@ describe "Viewing sidebar", type: :system do expect(header_dropdown).to be_visible end end + + describe "Community sidebar section", type: :system do + fab!(:user) { Fabricate(:user, locale: "pl_PL") } + fab!(:translation_override) do + TranslationOverride.create!( + locale: "pl_PL", + translation_key: "js.sidebar.sections.community.links.topics.content", + value: "Tematy", + ) + TranslationOverride.create!( + locale: "pl_PL", + translation_key: "js.sidebar.sections.community.links.topics.title", + value: "Wszystkie tematy", + ) + end + + before { SiteSetting.allow_user_locale = true } + + it "has correct translations" do + sign_in user + visit("/latest") + links = page.all("#sidebar-section-content-community .sidebar-section-link-wrapper a") + expect(links.map(&:text)).to eq(%w[Tematy Wysłane]) + expect(links.map { |link| link[:title] }).to eq( + ["Wszystkie tematy", "Moja ostatnia aktywność w temacie"], + ) + end + end end