Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates translations to use .org GlotPress #39

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion includes/blocks/mailchimp/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"text": true
}
},
"textdomain": "mailchimp_i18n",
"textdomain": "mailchimp",
"editorScript": "file:./index.js",
"render": "file:./markup.php",
"editorStyle": "file:./editor.css"
Expand Down
6 changes: 3 additions & 3 deletions includes/blocks/mailchimp/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export const BlockEdit = ({ isSelected }) => {
{isSelected || isDisallowedThemeSSR ? (
<Placeholder
icon={Icon}
label={__('Mailchimp Block', 'mailchimp_i18n')}
instructions={__('Great work! Your block is ready to go.', 'mailchimp_i18n')}
label={__('Mailchimp Block', 'mailchimp')}
instructions={__('Great work! Your block is ready to go.', 'mailchimp')}
>
<div>
<Button
Expand All @@ -42,7 +42,7 @@ export const BlockEdit = ({ isSelected }) => {
>
{__(
"Head over here if you'd like to adjust your settings.",
'mailchimp_i18n',
'mailchimp',
)}
</Button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions lib/mailchimp/mailchimp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
Expand Down
89 changes: 40 additions & 49 deletions mailchimp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand All @@ -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 = '<a href="' . esc_url( $settings_page ) . '">' . esc_html__( 'Settings', 'mailchimp_i18n' ) . '</a>';
$settings_link = '<a href="' . esc_url( $settings_page ) . '">' . esc_html__( 'Settings', 'mailchimp' ) . '</a>';
array_unshift( $links, $settings_link );
return $links;
}
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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' );
Expand Down Expand Up @@ -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 = '<p class="success_msg">' . __( 'Fancy Javascript submission turned On!', 'mailchimp_i18n' ) . '</p>';
$msg = '<p class="success_msg">' . esc_html__( 'Fancy Javascript submission turned On!', 'mailchimp' ) . '</p>';
mailchimp_sf_global_msg( $msg );
} elseif ( get_option( 'mc_use_javascript' ) !== 'off' ) {
update_option( 'mc_use_javascript', 'off' );
$msg = '<p class="success_msg">' . __( 'Fancy Javascript submission turned Off!', 'mailchimp_i18n' ) . '</p>';
$msg = '<p class="success_msg">' . esc_html__( 'Fancy Javascript submission turned Off!', 'mailchimp' ) . '</p>';
mailchimp_sf_global_msg( $msg );
}

if ( isset( $_POST['mc_use_datepicker'] ) ) {
update_option( 'mc_use_datepicker', 'on' );
$msg = '<p class="success_msg">' . __( 'Datepicker turned On!', 'mailchimp_i18n' ) . '</p>';
$msg = '<p class="success_msg">' . esc_html__( 'Datepicker turned On!', 'mailchimp' ) . '</p>';
mailchimp_sf_global_msg( $msg );
} elseif ( get_option( 'mc_use_datepicker' ) !== 'off' ) {
update_option( 'mc_use_datepicker', 'off' );
$msg = '<p class="success_msg">' . __( 'Datepicker turned Off!', 'mailchimp_i18n' ) . '</p>';
$msg = '<p class="success_msg">' . esc_html__( 'Datepicker turned Off!', 'mailchimp' ) . '</p>';
mailchimp_sf_global_msg( $msg );
}

/*Enable double optin toggle*/
if ( isset( $_POST['mc_double_optin'] ) ) {
update_option( 'mc_double_optin', true );
$msg = '<p class="success_msg">' . __( 'Double opt-in turned On!', 'mailchimp_i18n' ) . '</p>';
$msg = '<p class="success_msg">' . esc_html__( 'Double opt-in turned On!', 'mailchimp' ) . '</p>';
mailchimp_sf_global_msg( $msg );
} elseif ( get_option( 'mc_double_optin' ) !== false ) {
update_option( 'mc_double_optin', false );
$msg = '<p class="success_msg">' . __( 'Double opt-in turned Off!', 'mailchimp_i18n' ) . '</p>';
$msg = '<p class="success_msg">' . esc_html__( 'Double opt-in turned Off!', 'mailchimp' ) . '</p>';
mailchimp_sf_global_msg( $msg );
}

/* NUKE the CSS! */
if ( isset( $_POST['mc_nuke_all_styles'] ) ) {
update_option( 'mc_nuke_all_styles', true );
$msg = '<p class="success_msg">' . __( 'Mailchimp CSS turned Off!', 'mailchimp_i18n' ) . '</p>';
$msg = '<p class="success_msg">' . esc_html__( 'Mailchimp CSS turned Off!', 'mailchimp' ) . '</p>';
mailchimp_sf_global_msg( $msg );
} elseif ( get_option( 'mc_nuke_all_styles' ) !== false ) {
update_option( 'mc_nuke_all_styles', false );
$msg = '<p class="success_msg">' . __( 'Mailchimp CSS turned On!', 'mailchimp_i18n' ) . '</p>';
$msg = '<p class="success_msg">' . esc_html__( 'Mailchimp CSS turned On!', 'mailchimp' ) . '</p>';
mailchimp_sf_global_msg( $msg );
}

/* Update existing */
if ( isset( $_POST['mc_update_existing'] ) ) {
update_option( 'mc_update_existing', true );
$msg = '<p class="success_msg">' . __( 'Update existing subscribers turned On!' ) . '</p>';
$msg = '<p class="success_msg">' . esc_html__( 'Update existing subscribers turned On!' ) . '</p>';
mailchimp_sf_global_msg( $msg );
} elseif ( get_option( 'mc_update_existing' ) !== false ) {
update_option( 'mc_update_existing', false );
$msg = '<p class="success_msg">' . __( 'Update existing subscribers turned Off!' ) . '</p>';
$msg = '<p class="success_msg">' . esc_html__( 'Update existing subscribers turned Off!' ) . '</p>';
mailchimp_sf_global_msg( $msg );
}

if ( isset( $_POST['mc_use_unsub_link'] ) ) {
update_option( 'mc_use_unsub_link', 'on' );
$msg = '<p class="success_msg">' . __( 'Unsubscribe link turned On!', 'mailchimp_i18n' ) . '</p>';
$msg = '<p class="success_msg">' . esc_html__( 'Unsubscribe link turned On!', 'mailchimp' ) . '</p>';
mailchimp_sf_global_msg( $msg );
} elseif ( get_option( 'mc_use_unsub_link' ) !== 'off' ) {
update_option( 'mc_use_unsub_link', 'off' );
$msg = '<p class="success_msg">' . __( 'Unsubscribe link turned Off!', 'mailchimp_i18n' ) . '</p>';
$msg = '<p class="success_msg">' . esc_html__( 'Unsubscribe link turned Off!', 'mailchimp' ) . '</p>';
mailchimp_sf_global_msg( $msg );
}

Expand Down Expand Up @@ -626,7 +622,7 @@ function mailchimp_sf_save_general_form_settings() {
}
}

$msg = '<p class="success_msg">' . esc_html( __( 'Successfully Updated your List Subscribe Form Settings!', 'mailchimp_i18n' ) ) . '</p>';
$msg = '<p class="success_msg">' . esc_html__( 'Successfully Updated your List Subscribe Form Settings!', 'mailchimp' ) . '</p>';
mailchimp_sf_global_msg( $msg );
}

Expand Down Expand Up @@ -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 = '<p class="success_msg">' .
sprintf(
// translators: placeholder is a count (number)
__( '<b>Success!</b> Loaded and saved the info for %d Merge Variables', 'mailchimp_i18n' ) . $igs_text,
/* translators: %s: count (number) */
__( '<b>Success!</b> Loaded and saved the info for %d Merge Variables', 'mailchimp' ) . $igs_text,
count( $mv )
) . ' ' .
__( 'from your list' ) . ' "' . $list_name . '"<br/><br/>' .
__( 'Now you should either Turn On the Mailchimp Widget or change your options below, then turn it on.', 'mailchimp_i18n' ) . '</p>';
esc_html__( 'from your list' ) . ' "' . $list_name . '"<br/><br/>' .
esc_html__( 'Now you should either Turn On the Mailchimp Widget or change your options below, then turn it on.', 'mailchimp' ) . '</p>';

mailchimp_sf_global_msg( $msg );
}
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -896,17 +893,17 @@ function mailchimp_sf_signup_submit() {
'<strong class="mc_error_msg">%s</strong>',
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 <a href="%2$s">sign up here.</a>',
'mailchimp_i18n'
'mailchimp'
),
esc_html( $email ),
esc_url( $url )
),
[
'a' => [
'href',
'href' => [],
],
]
)
Expand All @@ -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( '<strong class="mc_error_msg">' . $msg . '</strong>' );
return false;
Expand All @@ -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 = "<strong class='mc_success_msg'>{$esc}</strong>";
} 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 = "<strong class='mc_success_msg'>{$esc}</strong>";
}

Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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 );
}
}
Expand Down Expand Up @@ -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 );
}
Expand Down
Loading
Loading