mirror of
https://github.com/discourse/discourse.git
synced 2026-03-03 23:54:20 +08:00
Reported here: https://meta.discourse.org/t/labels-and-descriptions-missing-from-nested-object-settings/394685 Descriptions for nested object settings were not being displayed due to a mismatch in locale key formatting. Stripping `.schema.properties.` so that the locale keys from the serializer match the keys expected in the template fixes it Before: <img width="600" alt="image" src="https://github.com/user-attachments/assets/1e0ab4c6-e6eb-478d-97bc-76f16739135b" /> After: <img width="600" alt="image" src="https://github.com/user-attachments/assets/a9a9e64c-4efa-4807-94a1-dd853ffd9f04" />
29 lines
833 B
Ruby
29 lines
833 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ThemeObjectsSettingMetadataSerializer < ApplicationSerializer
|
|
attributes :categories, :property_descriptions
|
|
|
|
def categories
|
|
object
|
|
.categories(scope)
|
|
.reduce({}) do |acc, category|
|
|
acc[category.id] = BasicCategorySerializer.new(category, scope: scope, root: false).as_json
|
|
acc
|
|
end
|
|
end
|
|
|
|
def property_descriptions
|
|
locales = {}
|
|
key = "theme_metadata.settings.#{object.name}.schema.properties."
|
|
|
|
object.theme.internal_translations.each do |internal_translation|
|
|
if internal_translation.key.start_with?(key)
|
|
locale_key = internal_translation.key.delete_prefix(key)
|
|
locale_key = locale_key.gsub(".schema.properties.", ".")
|
|
locales[locale_key] = internal_translation.value
|
|
end
|
|
end
|
|
|
|
locales
|
|
end
|
|
end
|