Add ability to translate server rules (#34494)

This commit is contained in:
Claire 2025-05-21 13:54:12 +02:00 committed by GitHub
commit 8c51a8ba94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 149 additions and 20 deletions

View file

@ -0,0 +1,27 @@
%tr.nested-fields
%td
.fields-row
.fields-row__column.fields-group
= f.input :language,
collection: ui_languages,
include_blank: false,
label_method: ->(locale) { native_locale_name(locale) }
.fields-row__column.fields-group
= f.hidden_field :id if f.object&.persisted? # Required so Rails doesn't put the field outside of the <tr/>
= link_to_remove_association(f, class: 'table-action-link') do
= safe_join([material_symbol('close'), t('filters.index.delete')])
.fields-group
= f.input :text,
label: I18n.t('simple_form.labels.rule.text'),
hint: I18n.t('simple_form.hints.rule.text'),
input_html: { lang: f.object&.language },
wrapper: :with_block_label
.fields-group
= f.input :hint,
label: I18n.t('simple_form.labels.rule.hint'),
hint: I18n.t('simple_form.hints.rule.hint'),
input_html: { lang: f.object&.language },
wrapper: :with_block_label

View file

@ -6,5 +6,26 @@
= render form
%hr.spacer/
%h4= t('admin.rules.translations')
%p.hint= t('admin.rules.translations_explanation')
.table-wrapper
%table.table.keywords-table
%thead
%tr
%th= t('admin.rules.translation')
%th
%tbody
= form.simple_fields_for :translations do |translation|
= render 'translation_fields', f: translation
%tfoot
%tr
%td{ colspan: 3 }
= link_to_add_association form, :translations, class: 'table-action-link', partial: 'translation_fields', 'data-association-insertion-node': '.keywords-table tbody', 'data-association-insertion-method': 'append' do
= safe_join([material_symbol('add'), t('admin.rules.add_translation')])
.actions
= form.button :button, t('generic.save_changes'), type: :submit