Skip to content

Commit e74772e

Browse files
authored
FIX: Update i18n key for toggle localization button (#34405)
When this button was moved from translator to core (discourse/discourse-translator#308) the translations were not updated. This commit fixes the missing translation.
1 parent f0fc564 commit e74772e

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

app/assets/javascripts/discourse/app/components/topic-localized-content-toggle.gjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export default class TopicLocalizedContentToggle extends Component {
3535

3636
get title() {
3737
return this.showingOriginal
38-
? "translator.content_not_translated"
39-
: "translator.content_translated";
38+
? "content_localization.toggle_localized.not_translated"
39+
: "content_localization.toggle_localized.translated";
4040
}
4141

4242
<template>

config/locales/client.en.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5580,6 +5580,10 @@ en:
55805580
default: "%{filter} topics in %{category} without tags"
55815581

55825582
categories: "All categories"
5583+
content_localization:
5584+
toggle_localized:
5585+
translated: "Page is machine-translated. Click to view original."
5586+
not_translated: "Page is not translated. Click to translate."
55835587

55845588
# This section is exported to the javascript for i18n in the admin section
55855589
admin_js:

spec/system/content_localization_spec.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# frozen_string_literal: true
22

33
describe "Content Localization" do
4+
TOGGLE_LOCALIZE_BUTTON_SELECTOR = "button.btn-toggle-localized-content"
5+
46
fab!(:japanese_user) { Fabricate(:user, locale: "ja") }
57
fab!(:site_local_user) { Fabricate(:user, locale: "en") }
68
fab!(:admin)
@@ -68,9 +70,16 @@
6870
topic_list.visit_topic_with_title("孫子兵法からの人生戦略")
6971

7072
expect(topic_page.has_topic_title?("孫子兵法からの人生戦略")).to eq(true)
71-
page.find("button.btn-toggle-localized-content").click
73+
74+
expect(page.find(TOGGLE_LOCALIZE_BUTTON_SELECTOR)["title"]).to eq(
75+
I18n.t("js.content_localization.toggle_localized.translated"),
76+
)
77+
page.find(TOGGLE_LOCALIZE_BUTTON_SELECTOR).click
7278

7379
expect(topic_page.has_topic_title?("Life strategies from The Art of War")).to eq(true)
80+
expect(page.find(TOGGLE_LOCALIZE_BUTTON_SELECTOR)["title"]).to eq(
81+
I18n.t("js.content_localization.toggle_localized.not_translated"),
82+
)
7483

7584
visit("/")
7685
topic_list.visit_topic_with_title("Life strategies from The Art of War")

0 commit comments

Comments
 (0)