Browse Source

Add publish_button_text site setting

Effy Elden 1 year ago
parent
commit
aeed3a9a1b

+ 4 - 2
app/javascript/mastodon/features/compose/components/compose_form.js

@@ -21,6 +21,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
 import { length } from 'stringz';
 import { countableText } from '../util/counter';
 import Icon from 'mastodon/components/icon';
+import { publish_button_text } from 'mastodon/initial_state';
 
 const allowedAroundShortCode = '><\u0085\u0020\u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\u0009\u000a\u000b\u000c\u000d';
 
@@ -211,13 +212,14 @@ class ComposeForm extends ImmutablePureComponent {
     const disabled = this.props.isSubmitting;
 
     let publishText = '';
+    let publishButtonText = publish_button_text || intl.formatMessage(messages.publish);
 
     if (this.props.isEditing) {
       publishText = intl.formatMessage(messages.saveChanges);
     } else if (this.props.privacy === 'private' || this.props.privacy === 'direct') {
-      publishText = <span className='compose-form__publish-private'><Icon id='lock' /> {intl.formatMessage(messages.publish)}</span>;
+      publishText = <span className='compose-form__publish-private'><Icon id='lock' /> {publishButtonText}</span>;
     } else {
-      publishText = this.props.privacy !== 'unlisted' ? intl.formatMessage(messages.publishLoud, { publish: intl.formatMessage(messages.publish) }) : intl.formatMessage(messages.publish);
+      publishText = this.props.privacy !== 'unlisted' ? intl.formatMessage(messages.publishLoud, { publish: publishButtonText }) : publishButtonText;
     }
 
     return (

+ 2 - 0
app/javascript/mastodon/initial_state.js

@@ -80,6 +80,7 @@
  * @property {boolean=} use_pending_items
  * @property {string} version
  * @property {boolean} translation_enabled
+ * @property {string} publish_button_text
  */
 
 /**
@@ -132,5 +133,6 @@ export const usePendingItems = getMeta('use_pending_items');
 export const version = getMeta('version');
 export const translationEnabled = getMeta('translation_enabled');
 export const languages = initialState?.languages;
+export const publish_button_text = getMeta('publish_button_text');
 
 export default initialState;

+ 1 - 0
app/models/form/admin_settings.rb

@@ -31,6 +31,7 @@ class Form::AdminSettings
     media_cache_retention_period
     content_cache_retention_period
     backups_retention_period
+    publish_button_text
   ).freeze
 
   INTEGER_KEYS = %i(

+ 1 - 0
app/serializers/initial_state_serializer.rb

@@ -32,6 +32,7 @@ class InitialStateSerializer < ActiveModel::Serializer
       activity_api_enabled: Setting.activity_api_enabled,
       single_user_mode: Rails.configuration.x.single_user_mode,
       translation_enabled: TranslationService.configured?,
+      publish_button_text: Setting.publish_button_text,
     }
 
     if object.current_account

+ 3 - 0
app/views/admin/settings/appearance/show.html.haml

@@ -30,5 +30,8 @@
           = fa_icon 'trash fw'
           = t('admin.site_uploads.delete')
 
+  .fields-group
+    = f.input :publish_button_text, wrapper: :with_block_label
+
   .actions
     = f.button :button, t('generic.save_changes'), type: :submit

+ 1 - 0
config/locales/simple_form.en.yml

@@ -82,6 +82,7 @@ en:
         mascot: Overrides the illustration in the advanced web interface.
         media_cache_retention_period: Downloaded media files will be deleted after the specified number of days when set to a positive value, and re-downloaded on demand.
         profile_directory: The profile directory lists all users who have opted-in to be discoverable.
+        publish_button_text: Overrides the text of the publish button.
         require_invite_text: When sign-ups require manual approval, make the “Why do you want to join?” text input mandatory rather than optional
         site_contact_email: How people can reach you for legal or support inquiries.
         site_contact_username: How people can reach you on Mastodon.

+ 1 - 0
config/settings.yml

@@ -70,6 +70,7 @@ defaults: &defaults
   show_domain_blocks_rationale: 'disabled'
   require_invite_text: false
   backups_retention_period: 7
+  publish_button_text: ''
 
 development:
   <<: *defaults