discourse/lib/topic_localization_creator.rb
Natalie Tay 3f8ccda7aa
FEATURE: Allow post authors to localize their own posts (#36178)
We should allow authors to localize their own content.

This is gated behind the
`content_localization_allow_author_localization` setting, which is
enabled by default.

Meta:
https://meta.discourse.org/t/feature-request-allow-users-to-localize-only-their-own-topics/389147
2025-11-25 11:02:22 +08:00

15 lines
370 B
Ruby
Vendored

# frozen_string_literal: true
class TopicLocalizationCreator
def self.create(topic_id:, locale:, title:, user:)
Guardian.new(user).ensure_can_localize_topic!(topic_id)
TopicLocalization.create!(
topic_id: topic_id,
locale: locale,
title: title,
fancy_title: Topic.fancy_title(title),
localizer_user_id: user.id,
)
end
end