diff --git a/README.md b/README.md index 743db4d..a7f4e0d 100644 --- a/README.md +++ b/README.md @@ -89,16 +89,6 @@ Currently we have the plugin configured so it can be translated and the followin * sv_SE - Swedish in Sweden (thanks to [Sebastian Johnsson](http://www.agiley.se/) for contributing) * tr_TR - Turkish in Turkey (thanks to [Hakan E.](http://kazancexpert.com/) for contributing) -If your language is not listed above, feel free to create a translation. Here are the basic steps: - -1. Copy "mailchimp_i18n-en_US.po" to "mailchimp_i18n-LANG_COUNTRY.po" - fill in LANG and COUNTRY with whatever you use for WPLANG in wp-config.php -2. Grab a translation editor. [POedit](http://www.poedit.net/) works for us -3. Translate each line - if you need some context, open up mailchimp.php and search for the line number or text -4. [Fork](http://help.github.com/fork-a-repo/) the [repository on github](https://github.com/mailchimp/wordpress) -5. [Clone](http://help.github.com/remotes/#clone) the _develop_ branch -6. Add the appropriately named files to the /po/ directory and edit the /readme.txt to include how you'd like to be attributed -7. Make a [pull request](http://help.github.com/send-pull-requests/) - ## Support Level **Active:** Mailchimp is actively working on this, and we expect to continue work for the foreseeable future including keeping tested up to the most recent version of WordPress. Bug reports, feature requests, questions, and pull requests are welcome. diff --git a/includes/blocks/mailchimp/block.json b/includes/blocks/mailchimp/block.json index ab89575..0f2fe71 100644 --- a/includes/blocks/mailchimp/block.json +++ b/includes/blocks/mailchimp/block.json @@ -35,7 +35,7 @@ "text": true } }, - "textdomain": "mailchimp_i18n", + "textdomain": "mailchimp", "editorScript": "file:./index.js", "render": "file:./markup.php", "editorStyle": "file:./editor.css" diff --git a/includes/blocks/mailchimp/edit.js b/includes/blocks/mailchimp/edit.js index b83b450..3083d59 100644 --- a/includes/blocks/mailchimp/edit.js +++ b/includes/blocks/mailchimp/edit.js @@ -31,8 +31,8 @@ export const BlockEdit = ({ isSelected }) => { {isSelected || isDisallowedThemeSSR ? (
diff --git a/lib/mailchimp/mailchimp.php b/lib/mailchimp/mailchimp.php index 07f9273..a310ba0 100644 --- a/lib/mailchimp/mailchimp.php +++ b/lib/mailchimp/mailchimp.php @@ -50,8 +50,8 @@ public function __construct( $api_key ) { throw new Exception( esc_html( sprintf( - // translators: placeholder is an api key - __( 'Invalid API Key: %s', 'mailchimp_i18n' ), + /* translators: %s: api key */ + __( 'Invalid API Key: %s', 'mailchimp' ), $api_key ) ) diff --git a/mailchimp.php b/mailchimp.php index 4dba8f7..636ba20 100644 --- a/mailchimp.php +++ b/mailchimp.php @@ -3,6 +3,7 @@ * Plugin Name: Mailchimp * Plugin URI: https://mailchimp.com/help/connect-or-disconnect-list-subscribe-for-wordpress/ * Description: Add a Mailchimp signup form widget to your WordPress site. + * Text Domain: mailchimp * Version: 1.5.8 * Requires at least: 6.1 * Requires PHP: 7.0 @@ -60,16 +61,11 @@ /** * Do the following plugin setup steps here * - * Internationalization * Resource (JS & CSS) enqueuing * * @return void */ function mailchimp_sf_plugin_init() { - // Internationalize the plugin - $textdomain = 'mailchimp_i18n'; - $locale = apply_filters( 'plugin_locale', get_locale(), $textdomain ); - load_textdomain( 'mailchimp_i18n', MCSF_LANG_DIR . $textdomain . '-' . $locale . '.mo' ); // Remove Sopresto check. If user does not have API key, make them authenticate. @@ -91,7 +87,7 @@ function mailchimp_sf_plugin_init() { */ function mailchimp_sf_plugin_action_links( $links ) { $settings_page = add_query_arg( array( 'page' => 'mailchimp_sf_options' ), admin_url( 'admin.php' ) ); - $settings_link = '' . esc_html__( 'Settings', 'mailchimp_i18n' ) . ''; + $settings_link = '' . esc_html__( 'Settings', 'mailchimp' ) . ''; array_unshift( $links, $settings_link ); return $links; } @@ -203,8 +199,8 @@ function mailchimp_sf_main_css() { function mailchimp_sf_add_pages() { // Add settings page for users who can edit plugins add_menu_page( - __( 'Mailchimp Setup', 'mailchimp_i18n' ), - __( 'Mailchimp', 'mailchimp_i18n' ), + esc_html__( 'Mailchimp Setup', 'mailchimp' ), + esc_html__( 'Mailchimp', 'mailchimp' ), MCSF_CAP_THRESHOLD, 'mailchimp_sf_options', 'mailchimp_sf_setup_page', @@ -482,8 +478,8 @@ function mailchimp_sf_global_msg( $msg = null ) { * @return void */ function mailchimp_sf_set_form_defaults( $list_name = '' ) { - update_option( 'mc_header_content', __( 'Sign up for', 'mailchimp_i18n' ) . ' ' . $list_name ); - update_option( 'mc_submit_text', __( 'Subscribe', 'mailchimp_i18n' ) ); + update_option( 'mc_header_content', esc_html__( 'Sign up for', 'mailchimp' ) . ' ' . $list_name ); + update_option( 'mc_submit_text', esc_html__( 'Subscribe', 'mailchimp' ) ); update_option( 'mc_use_datepicker', 'on' ); update_option( 'mc_custom_style', 'off' ); @@ -511,64 +507,64 @@ function mailchimp_sf_save_general_form_settings() { // IF NOT DEV MODE if ( isset( $_POST['mc_use_javascript'] ) ) { update_option( 'mc_use_javascript', 'on' ); - $msg = '

' . __( 'Fancy Javascript submission turned On!', 'mailchimp_i18n' ) . '

'; + $msg = '

' . esc_html__( 'Fancy Javascript submission turned On!', 'mailchimp' ) . '

'; mailchimp_sf_global_msg( $msg ); } elseif ( get_option( 'mc_use_javascript' ) !== 'off' ) { update_option( 'mc_use_javascript', 'off' ); - $msg = '

' . __( 'Fancy Javascript submission turned Off!', 'mailchimp_i18n' ) . '

'; + $msg = '

' . esc_html__( 'Fancy Javascript submission turned Off!', 'mailchimp' ) . '

'; mailchimp_sf_global_msg( $msg ); } if ( isset( $_POST['mc_use_datepicker'] ) ) { update_option( 'mc_use_datepicker', 'on' ); - $msg = '

' . __( 'Datepicker turned On!', 'mailchimp_i18n' ) . '

'; + $msg = '

' . esc_html__( 'Datepicker turned On!', 'mailchimp' ) . '

'; mailchimp_sf_global_msg( $msg ); } elseif ( get_option( 'mc_use_datepicker' ) !== 'off' ) { update_option( 'mc_use_datepicker', 'off' ); - $msg = '

' . __( 'Datepicker turned Off!', 'mailchimp_i18n' ) . '

'; + $msg = '

' . esc_html__( 'Datepicker turned Off!', 'mailchimp' ) . '

'; mailchimp_sf_global_msg( $msg ); } /*Enable double optin toggle*/ if ( isset( $_POST['mc_double_optin'] ) ) { update_option( 'mc_double_optin', true ); - $msg = '

' . __( 'Double opt-in turned On!', 'mailchimp_i18n' ) . '

'; + $msg = '

' . esc_html__( 'Double opt-in turned On!', 'mailchimp' ) . '

'; mailchimp_sf_global_msg( $msg ); } elseif ( get_option( 'mc_double_optin' ) !== false ) { update_option( 'mc_double_optin', false ); - $msg = '

' . __( 'Double opt-in turned Off!', 'mailchimp_i18n' ) . '

'; + $msg = '

' . esc_html__( 'Double opt-in turned Off!', 'mailchimp' ) . '

'; mailchimp_sf_global_msg( $msg ); } /* NUKE the CSS! */ if ( isset( $_POST['mc_nuke_all_styles'] ) ) { update_option( 'mc_nuke_all_styles', true ); - $msg = '

' . __( 'Mailchimp CSS turned Off!', 'mailchimp_i18n' ) . '

'; + $msg = '

' . esc_html__( 'Mailchimp CSS turned Off!', 'mailchimp' ) . '

'; mailchimp_sf_global_msg( $msg ); } elseif ( get_option( 'mc_nuke_all_styles' ) !== false ) { update_option( 'mc_nuke_all_styles', false ); - $msg = '

' . __( 'Mailchimp CSS turned On!', 'mailchimp_i18n' ) . '

'; + $msg = '

' . esc_html__( 'Mailchimp CSS turned On!', 'mailchimp' ) . '

'; mailchimp_sf_global_msg( $msg ); } /* Update existing */ if ( isset( $_POST['mc_update_existing'] ) ) { update_option( 'mc_update_existing', true ); - $msg = '

' . __( 'Update existing subscribers turned On!' ) . '

'; + $msg = '

' . esc_html__( 'Update existing subscribers turned On!' ) . '

'; mailchimp_sf_global_msg( $msg ); } elseif ( get_option( 'mc_update_existing' ) !== false ) { update_option( 'mc_update_existing', false ); - $msg = '

' . __( 'Update existing subscribers turned Off!' ) . '

'; + $msg = '

' . esc_html__( 'Update existing subscribers turned Off!' ) . '

'; mailchimp_sf_global_msg( $msg ); } if ( isset( $_POST['mc_use_unsub_link'] ) ) { update_option( 'mc_use_unsub_link', 'on' ); - $msg = '

' . __( 'Unsubscribe link turned On!', 'mailchimp_i18n' ) . '

'; + $msg = '

' . esc_html__( 'Unsubscribe link turned On!', 'mailchimp' ) . '

'; mailchimp_sf_global_msg( $msg ); } elseif ( get_option( 'mc_use_unsub_link' ) !== 'off' ) { update_option( 'mc_use_unsub_link', 'off' ); - $msg = '

' . __( 'Unsubscribe link turned Off!', 'mailchimp_i18n' ) . '

'; + $msg = '

' . esc_html__( 'Unsubscribe link turned Off!', 'mailchimp' ) . '

'; mailchimp_sf_global_msg( $msg ); } @@ -626,7 +622,7 @@ function mailchimp_sf_save_general_form_settings() { } } - $msg = '

' . esc_html( __( 'Successfully Updated your List Subscribe Form Settings!', 'mailchimp_i18n' ) ) . '

'; + $msg = '

' . esc_html__( 'Successfully Updated your List Subscribe Form Settings!', 'mailchimp' ) . '

'; mailchimp_sf_global_msg( $msg ); } @@ -684,18 +680,19 @@ function mailchimp_sf_change_list_if_necessary() { $igs_text = ' '; if ( is_array( $igs ) ) { - // translators: placeholder is a count (number) - $igs_text .= sprintf( __( 'and %s Sets of Interest Groups', 'mailchimp_i18n' ), count( $igs ) ); + /* translators: %s: count (number) */ + $igs_text .= sprintf( esc_html__( 'and %s Sets of Interest Groups', 'mailchimp' ), count( $igs ) ); } $msg = '

' . sprintf( - // translators: placeholder is a count (number) - __( 'Success! Loaded and saved the info for %d Merge Variables', 'mailchimp_i18n' ) . $igs_text, + /* translators: %s: count (number) */ + __( 'Success! Loaded and saved the info for %d Merge Variables', 'mailchimp' ) . $igs_text, count( $mv ) ) . ' ' . - __( 'from your list' ) . ' "' . $list_name . '"

' . - __( 'Now you should either Turn On the Mailchimp Widget or change your options below, then turn it on.', 'mailchimp_i18n' ) . '

'; + esc_html__( 'from your list' ) . ' "' . $list_name . '"

' . + esc_html__( 'Now you should either Turn On the Mailchimp Widget or change your options below, then turn it on.', 'mailchimp' ) . '

'; + mailchimp_sf_global_msg( $msg ); } } @@ -738,7 +735,7 @@ function mailchimp_sf_get_merge_vars( $list_id, $new_list ) { function mailchimp_sf_add_email_field( $merge ) { $email = array( 'tag' => 'EMAIL', - 'name' => __( 'Email Address', 'mailchimp_i18n' ), + 'name' => esc_html__( 'Email Address', 'mailchimp' ), 'type' => 'email', 'required' => true, 'public' => true, @@ -896,17 +893,17 @@ function mailchimp_sf_signup_submit() { '%s', wp_kses( sprintf( - // translators: first placeholder is email address, second is url + /* translators: 1: email address 2: url */ __( 'We encountered a problem adding %1$s to the list. Please sign up here.', - 'mailchimp_i18n' + 'mailchimp' ), esc_html( $email ), esc_url( $url ) ), [ 'a' => [ - 'href', + 'href' => [], ], ] ) @@ -920,7 +917,7 @@ function mailchimp_sf_signup_submit() { // If update existing is turned off and the subscriber exists, error out. if ( get_option( 'mc_update_existing' ) === false && 'subscribed' === $status ) { - $msg = 'This email address is already subscribed to the list.'; + $msg = esc_html__( 'This email address is already subscribed to the list.', 'mailchimp' ); $error = new WP_Error( 'mailchimp-update-existing', $msg ); mailchimp_sf_global_msg( '' . $msg . '' ); return false; @@ -937,10 +934,10 @@ function mailchimp_sf_signup_submit() { } if ( 'subscribed' === $retval['status'] ) { - $esc = __( 'Success, you\'ve been signed up.', 'mailchimp_i18n' ); + $esc = esc_html__( 'Success, you\'ve been signed up.', 'mailchimp' ); $msg = "{$esc}"; } else { - $esc = __( 'Success, you\'ve been signed up! Please look for our confirmation email.', 'mailchimp_i18n' ); + $esc = esc_html__( 'Success, you\'ve been signed up! Please look for our confirmation email.', 'mailchimp' ); $msg = "{$esc}"; } @@ -1044,8 +1041,8 @@ function mailchimp_sf_merge_submit( $mv ) { } if ( 'Y' === $mv_var['required'] && trim( $opt_val ) === '' ) { - // translators: placeholder is field name - $message = sprintf( __( 'You must fill in %s.', 'mailchimp_i18n' ), esc_html( $mv_var['name'] ) ); + /* translators: %s: field name */ + $message = sprintf( esc_html__( 'You must fill in %s.', 'mailchimp' ), esc_html( $mv_var['name'] ) ); $error = new WP_Error( 'missing_required_field', $message ); return $error; } elseif ( 'EMAIL' !== $tag ) { @@ -1076,8 +1073,8 @@ function mailchimp_sf_merge_validate_phone( $opt_val, $data ) { } if ( ! preg_match( '/[0-9]{0,3}-[0-9]{0,3}-[0-9]{0,4}/A', $opt_val ) ) { - // translators: placeholder is field name - $message = sprintf( __( '%s must consist of only numbers', 'mailchimp_i18n' ), esc_html( $data['name'] ) ); + /* translators: %s: field name */ + $message = sprintf( esc_html__( '%s must consist of only numbers', 'mailchimp' ), esc_html( $data['name'] ) ); $error = new WP_Error( 'mc_phone_validation', $message ); return $error; } @@ -1095,8 +1092,8 @@ function mailchimp_sf_merge_validate_phone( $opt_val, $data ) { function mailchimp_sf_merge_validate_address( $opt_val, $data ) { if ( 'Y' === $data['required'] ) { if ( empty( $opt_val['addr1'] ) || empty( $opt_val['city'] ) ) { - // translators: placeholder is field name - $message = sprintf( __( 'You must fill in %s.', 'mailchimp_i18n' ), esc_html( $data['name'] ) ); + /* translators: %s: field name */ + $message = sprintf( esc_html__( 'You must fill in %s.', 'mailchimp' ), esc_html( $data['name'] ) ); $error = new WP_Error( 'invalid_address_merge', $message ); return $error; } @@ -1222,7 +1219,7 @@ function mailchimp_sf_verify_key( $api ) { update_option( 'mc_datacenter', $api->datacenter ); } else { - $msg = __( 'API Key must belong to "Owner", "Admin", or "Manager."', 'mailchimp_i18n' ); + $msg = esc_html__( 'API Key must belong to "Owner", "Admin", or "Manager."', 'mailchimp' ); return new WP_Error( 'mc-invalid-role', $msg ); } } @@ -1315,12 +1312,6 @@ function mailchimp_sf_where_am_i() { // Define our complete filesystem path define( 'MCSF_DIR', $mscf_dir ); - /** - * Lang location needs to be relative *from* ABSPATH, - * so strip it out of our language dir location - */ - define( 'MCSF_LANG_DIR', trailingslashit( MCSF_DIR ) . 'po/' ); - // Define our complete URL to the plugin folder define( 'MCSF_URL', $mscf_url ); } diff --git a/mailchimp_widget.php b/mailchimp_widget.php index b34c9bb..0e490db 100644 --- a/mailchimp_widget.php +++ b/mailchimp_widget.php @@ -30,7 +30,7 @@ function mailchimp_sf_signup_form( $args = array() ) { echo wp_kses( __( 'Sorry, there was a problem loading your Mailchimp details. Please navigate to Settings and click Mailchimp Setup to try again.', - 'mailchimp_i18n' + 'mailchimp' ), [ 'strong' => [], @@ -197,7 +197,7 @@ function mailchimp_sf_signup_form( $args = array() ) { if ( $num_fields > 1 ) { ?>
- * = + * =
- +
    -
  • -
  • +
  • +
@@ -262,7 +262,7 @@ function mailchimp_sf_signup_form( $args = array() ) { $host = 'http://' . $api->datacenter . '.list-manage.com'; ?> ' . __( 'Street Address', 'mailchimp_i18n' ) . ' + - + - + - + - + - + - + - + @@ -83,11 +83,11 @@ if ( '' !== $user && isset( $user['username'] ) && $user['username'] ) { ?> - @@ -117,12 +117,12 @@ if ( $api ) { ?> -

+

-

-

+

+

Mailchimp" ); ?> @@ -147,9 +147,9 @@

:

+

:

- +
- + - +
@@ -181,12 +181,12 @@

- +

-

:

-

:

+

:

+

:

- +
Content Options
- +
- +
- +
- .
- +
+
- + @@ -238,10 +238,10 @@
-
+
- +
Remove Mailchimp CSS
onclick="showMe('mc-custom-styling')"/>
@@ -250,11 +250,11 @@ - +
Custom Styling
- + @@ -264,82 +264,82 @@
- + - px + px
- + # - # + #
- + # - # + #
- + # - # + #
-
+
- + - + - + - + - + - +
List Options
id="mc_use_javascript" class="code" /> - +
id="mc_use_datepicker" class="code" /> - +
id="mc_double_optin" class="code" /> - +
id="mc_update_existing" class="code" /> - +
id="mc_use_unsub_link" class="code" /> - +
@@ -348,29 +348,29 @@
-
+
- - - - + + + +
- + - +
-
+
-

+

- + - + /> - + - +