mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-28 07:19:11 +08:00
## 🔍 Overview This update adds the ability for users to manually add translations to specific posts. It adds a 🌐 icon on the post menu where you can click to add translations for posts. It also introduces a new site setting: `content_localization_debug_allowed_groups` which is convenient when debugging localized posts. It adds a globe icon in the post meta data area along with a number of how many languages the post is translated in. Hovering over the icon will show a tooltip with access to editing and deleting the translated posts. ## 📸 Screenshots <img width="1234" alt="Screenshot 2025-05-07 at 13 26 09" src="https://github.com/user-attachments/assets/9d65374d-ee3e-4e8b-b171-b98db6f90f23" /> <img width="300" alt="Screenshot 2025-05-07 at 13 26 41" src="https://github.com/user-attachments/assets/6ee9c5e6-16ed-4dab-97ec-9401804a4ac8" />
42 lines
1.6 KiB
Ruby
Vendored
42 lines
1.6 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
describe "Post translations", type: :system do
|
|
fab!(:user)
|
|
fab!(:topic)
|
|
fab!(:post) { Fabricate(:post, topic: topic, user: user) }
|
|
let(:topic_page) { PageObjects::Pages::Topic.new }
|
|
let(:composer) { PageObjects::Components::Composer.new }
|
|
let(:translation_selector) do
|
|
PageObjects::Components::SelectKit.new(".translation-selector-dropdown")
|
|
end
|
|
|
|
before do
|
|
sign_in(user)
|
|
SiteSetting.experimental_content_localization = true
|
|
SiteSetting.experimental_content_localization_allowed_groups = Group::AUTO_GROUPS[:everyone]
|
|
SiteSetting.post_menu =
|
|
"read|like|copyLink|flag|edit|bookmark|delete|admin|reply|addTranslation"
|
|
end
|
|
|
|
it "allows a user to translate a post" do
|
|
topic_page.visit_topic(topic)
|
|
find("#post_#{post.post_number} .post-action-menu__add-translation").click
|
|
expect(composer).to be_opened
|
|
translation_selector.expand
|
|
translation_selector.select_row_by_value("fr")
|
|
find("#translated-topic-title").fill_in(with: "Ceci est un sujet de test 0")
|
|
composer.fill_content("Bonjour le monde")
|
|
composer.submit
|
|
post.reload
|
|
topic.reload
|
|
|
|
try_until_success do
|
|
expect(TopicLocalization.exists?(topic_id: topic.id, locale: "fr")).to be true
|
|
expect(PostLocalization.exists?(post_id: post.id, locale: "fr")).to be true
|
|
expect(PostLocalization.find_by(post_id: post.id, locale: "fr").raw).to eq("Bonjour le monde")
|
|
expect(TopicLocalization.find_by(topic_id: topic.id, locale: "fr").title).to eq(
|
|
"Ceci est un sujet de test 0",
|
|
)
|
|
end
|
|
end
|
|
end
|