mirror of
https://github.com/mastodon/mastodon.git
synced 2025-05-07 20:26:15 +00:00
[WiP] Add admin interface to edit rule translations
This commit is contained in:
parent
7d58c23c0e
commit
7f0b5478e6
|
@ -54,7 +54,7 @@ module Admin
|
|||
|
||||
def resource_params
|
||||
params
|
||||
.expect(rule: [:text, :hint, :priority])
|
||||
.expect(rule: [:text, :hint, :priority, translations_attributes: [[:id, :language, :text, :hint, :_destroy]]])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,6 +20,7 @@ class Rule < ApplicationRecord
|
|||
self.discard_column = :deleted_at
|
||||
|
||||
has_many :translations, inverse_of: :rule, class_name: 'RuleTranslation', dependent: :destroy
|
||||
accepts_nested_attributes_for :translations, reject_if: :all_blank, allow_destroy: true
|
||||
|
||||
validates :text, presence: true, length: { maximum: TEXT_SIZE_LIMIT }
|
||||
|
||||
|
|
27
app/views/admin/rules/_translation_fields.html.haml
Normal file
27
app/views/admin/rules/_translation_fields.html.haml
Normal 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
|
|
@ -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
|
||||
|
|
|
@ -786,11 +786,15 @@ en:
|
|||
title: Roles
|
||||
rules:
|
||||
add_new: Add rule
|
||||
add_translation: Add translation
|
||||
delete: Delete
|
||||
description_html: While most claim to have read and agree to the terms of service, usually people do not read through until after a problem arises. <strong>Make it easier to see your server's rules at a glance by providing them in a flat bullet point list.</strong> Try to keep individual rules short and simple, but try not to split them up into many separate items either.
|
||||
edit: Edit rule
|
||||
empty: No server rules have been defined yet.
|
||||
title: Server rules
|
||||
translation: Translation
|
||||
translations: Translations
|
||||
translations_explanation: You can optionally add translations for the rules. The default value will be shown if no translated version is available. Please always ensure any provided translation is in sync with the default value.
|
||||
settings:
|
||||
about:
|
||||
manage_rules: Manage server rules
|
||||
|
|
Loading…
Reference in New Issue
Block a user