From 6fc62586a2c0bd105f4da2c6d5c6f395e8da4360 Mon Sep 17 00:00:00 2001 From: Ted Johansson Date: Wed, 28 Jun 2023 19:03:04 +0800 Subject: [PATCH] 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. --- .../addon/controllers/admin-site-text-edit.js | 4 ++ .../admin/addon/templates/site-text-edit.hbs | 6 +++ .../stylesheets/common/admin/admin_base.scss | 11 +++++ .../admin/site_texts_controller.rb | 6 ++- app/models/translation_override.rb | 22 +++++++--- app/serializers/site_text_serializer.rb | 10 ++++- config/locales/client.en.yml | 1 + .../admin/site_texts_controller_spec.rb | 41 +++++++++++++++++++ 8 files changed, 93 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/admin/addon/controllers/admin-site-text-edit.js b/app/assets/javascripts/admin/addon/controllers/admin-site-text-edit.js index 8bcfc9b9da5..7dbc7229b21 100644 --- a/app/assets/javascripts/admin/addon/controllers/admin-site-text-edit.js +++ b/app/assets/javascripts/admin/addon/controllers/admin-site-text-edit.js @@ -48,4 +48,8 @@ export default Controller.extend(bufferedProperty("siteText"), { }, }); }, + + get interpolationKeys() { + return this.siteText.interpolation_keys.join(", "); + }, }); diff --git a/app/assets/javascripts/admin/addon/templates/site-text-edit.hbs b/app/assets/javascripts/admin/addon/templates/site-text-edit.hbs index 3643a123f8b..ef327ab4067 100644 --- a/app/assets/javascripts/admin/addon/templates/site-text-edit.hbs +++ b/app/assets/javascripts/admin/addon/templates/site-text-edit.hbs @@ -13,6 +13,12 @@ @class="site-text-value" /> + {{#if this.siteText.has_interpolation_keys}} +
{{i18n "admin.site_text.interpolation_keys"}} + {{this.interpolationKeys}} +
+ {{/if}} +