From a1e8c2b69dcc67f6d605e90368c0a062bbccec69 Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Thu, 23 Jan 2025 09:22:41 +0100 Subject: [PATCH] run stored textual settings through i18n to allow translating saved values. closes #793 --- includes/forms/class-form.php | 3 ++- includes/integrations/class-integration.php | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/forms/class-form.php b/includes/forms/class-form.php index 76a0b30f..11995a38 100755 --- a/includes/forms/class-form.php +++ b/includes/forms/class-form.php @@ -296,7 +296,8 @@ protected function load_messages(array $post_meta = []) $message_text = $post_meta[ 'text_' . $key ][0]; } - $messages[ $key ] = $message_text; + // run final value through gettext filter to allow translation of stored setting values + $messages[ $key ] = __($message_text, 'mailchimp-for-wp'); } return $messages; diff --git a/includes/integrations/class-integration.php b/includes/integrations/class-integration.php index 1f2edfcc..91c9e08e 100755 --- a/includes/integrations/class-integration.php +++ b/includes/integrations/class-integration.php @@ -175,6 +175,11 @@ public function get_label_text() $label = $default_options['label']; } + // run saved value through gettext filter + // this allows people to use a plugin like Loco Translate to translate this message + // without updating the setting itself + $label = __($label, 'mailchimp-for-wp'); + /** * Filters the checkbox label *