mirror of
https://github.com/discourse/discourse.git
synced 2025-06-20 13:41:34 +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" />
44 lines
1.1 KiB
Ruby
44 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class TopicLocalizationsController < ApplicationController
|
|
before_action :ensure_logged_in
|
|
|
|
def create_or_update
|
|
guardian.ensure_can_localize_content!
|
|
|
|
params.require(%i[topic_id locale title])
|
|
|
|
topic_localization =
|
|
TopicLocalization.find_by(topic_id: params[:topic_id], locale: params[:locale])
|
|
if topic_localization
|
|
TopicLocalizationUpdater.update(
|
|
topic_id: params[:topic_id],
|
|
locale: params[:locale],
|
|
title: params[:title],
|
|
user: current_user,
|
|
)
|
|
render json: success_json, status: :ok
|
|
else
|
|
TopicLocalizationCreator.create(
|
|
topic_id: params[:topic_id],
|
|
locale: params[:locale],
|
|
title: params[:title],
|
|
user: current_user,
|
|
)
|
|
render json: success_json, status: :created
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
guardian.ensure_can_localize_content!
|
|
|
|
params.require(%i[topic_id locale])
|
|
TopicLocalizationDestroyer.destroy(
|
|
topic_id: params[:topic_id],
|
|
locale: params[:locale],
|
|
acting_user: current_user,
|
|
)
|
|
head :no_content
|
|
end
|
|
end
|