mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
FEATURE: Show available interpolation keys when overriding translations (#22220)
This is the first of a number of PRs aimed at helping admins manage their translation overrides. It simply adds a list of available interpolation keys below the input field when editing an override. It also includes custom interpolation key.
This commit is contained in:
@ -156,8 +156,12 @@ class Admin::SiteTextsController < Admin::AdminController
|
||||
end
|
||||
|
||||
def record_for(key:, value: nil, locale:)
|
||||
en_key = TranslationOverride.transform_pluralized_key(key)
|
||||
value ||= I18n.with_locale(locale) { I18n.t(key) }
|
||||
{ id: key, value: value, locale: locale }
|
||||
interpolation_keys =
|
||||
I18nInterpolationKeysFinder.find(I18n.overrides_disabled { I18n.t(en_key, locale: :en) })
|
||||
custom_keys = TranslationOverride.custom_interpolation_keys(en_key)
|
||||
{ id: key, value: value, locale: locale, interpolation_keys: interpolation_keys + custom_keys }
|
||||
end
|
||||
|
||||
PLURALIZED_REGEX = /(.*)\.(zero|one|two|few|many|other)\z/
|
||||
|
Reference in New Issue
Block a user