mirror of
https://github.com/discourse/discourse.git
synced 2026-03-03 23:54:20 +08:00
This is a second attempt at: https://github.com/discourse/discourse/pull/33001 We had to [revert the commit](https://github.com/discourse/discourse/pull/33157) because it was performing a site-setting check at boot time, which is prone to issues and not allowed. This PR: - re-introduces the changes in the original PR - a fix by not performing a site-setting check at boot time (verified by: `SKIP_DB_AND_REDIS=1 DISCOURSE_DEV_DB="nonexist" bin/rails runner "puts 'booted'"` locally and should be caught by the new CI check introduced here: https://github.com/discourse/discourse/pull/33158) - adds a fix to the translation editor to not show the original post locale in the dropdown, as well as adding an indicator of what the original post locale is in a small badge in the header: - 
13 lines
409 B
Ruby
13 lines
409 B
Ruby
# frozen_string_literal: true
|
|
|
|
class PostLocalizationSerializer < ApplicationSerializer
|
|
attributes :id, :post_id, :post_version, :locale, :raw, :topic_localization
|
|
|
|
def topic_localization
|
|
TopicLocalizationSerializer.new(object.topic_localization, root: false).as_json
|
|
end
|
|
|
|
def include_topic_localization?
|
|
object.respond_to?(:topic_localization) && object.topic_localization.present?
|
|
end
|
|
end
|