mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 13:41:31 +08:00
FEATURE: Load theme setting descriptions from theme locale files
Previously theme setting descriptions were defined in the `settings.yml` file like this: ``` setting_name: default: "My Default Value" description: en: "English description" fr: "French description" ``` This commit allows developers to store the localised descriptions in the theme locale files instead: ``` en: theme_metadata: description: Theme Description settings: setting_name: "The localised description for setting_name" ```
This commit is contained in:
parent
a0a2823536
commit
03363d03e8
|
@ -367,7 +367,7 @@ class Theme < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def internal_translations
|
def internal_translations
|
||||||
translations(internal: true)
|
@internal_translations ||= translations(internal: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def translations(internal: false)
|
def translations(internal: false)
|
||||||
|
|
|
@ -21,7 +21,8 @@ class ThemeSettingsSerializer < ApplicationSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def description
|
def description
|
||||||
object.description
|
locale_file_description = object.theme.internal_translations.find { |t| t.key == "theme_metadata.settings.#{setting}" } &.value
|
||||||
|
locale_file_description || object.description
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid_values
|
def valid_values
|
||||||
|
@ -33,7 +34,7 @@ class ThemeSettingsSerializer < ApplicationSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def include_description?
|
def include_description?
|
||||||
object.description.present?
|
description.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_type
|
def list_type
|
||||||
|
|
|
@ -34,7 +34,7 @@ class ThemeSettingsManager
|
||||||
end
|
end
|
||||||
|
|
||||||
def description
|
def description
|
||||||
@opts[:description]
|
@opts[:description] # Old method of specifying description. Is now overridden by locale file
|
||||||
end
|
end
|
||||||
|
|
||||||
def value=(new_value)
|
def value=(new_value)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user