Helper: Add l10n functions to all strings

This commit is contained in:
Konstantin Kovshenin 2017-04-26 18:36:20 +03:00
parent 2e55b3076d
commit eacffb823a
4 changed files with 73 additions and 51 deletions

View File

@ -165,23 +165,30 @@ class WC_Helper {
case 'activate-success':
$subscription = self::_get_subscription_from_product_id( absint( $_GET['wc-helper-product-id'] ) );
$notices[] = array(
'message' => sprintf( '<strong>%s</strong> activated successfully. You will now receive updates for this product.', esc_html( $subscription['product_name'] ) ),
'type' => 'updated',
/* translators: %s: product name */
'message' => sprintf( __( '%s activated successfully. You will now receive updates for this product.', 'woocommerce' ),
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>' ),
);
break;
case 'activate-error':
$subscription = self::_get_subscription_from_product_id( absint( $_GET['wc-helper-product-id'] ) );
$notices[] = array(
'message' => sprintf( 'An error has occurred when activating <strong>%s</strong>. Please try again later.', esc_html( $subscription['product_name'] ) ),
'type' => 'error',
/* translators: %s: product name */
'message' => sprintf( __( 'An error has occurred when activating %s. Please try again later.', 'woocommerce' ),
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>' ),
);
break;
case 'deactivate-success':
$subscription = self::_get_subscription_from_product_id( absint( $_GET['wc-helper-product-id'] ) );
$local = self::_get_local_from_product_id( absint( $_GET['wc-helper-product-id'] ) );
$message = sprintf( 'Subscription for <strong>%s</strong> deactivated successfully. You will no longer receive updates for this product.', esc_html( $subscription['product_name'] ) );
/* translators: %s: product name */
$message = sprintf( __( 'Subscription for %s deactivated successfully. You will no longer receive updates for this product.', 'woocommerce' ),
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>' );
if ( $local && is_plugin_active( $local['_filename'] ) && current_user_can( 'activate_plugins' ) ) {
$deactivate_plugin_url = add_query_arg( array(
@ -191,7 +198,9 @@ class WC_Helper {
'wc-helper-nonce' => wp_create_nonce( 'deactivate-plugin:' . $subscription['product_id'] ),
), admin_url( 'admin.php' ) );
$message = sprintf( 'Subscription for <strong>%1$s</strong> deactivated successfully. You will no longer receive updates for this product. <a href="%2$s">Click here</a> if you wish to deactive the plugin as well.', esc_html( $subscription['product_name'] ), esc_url( $deactivate_plugin_url ) );
/* translators: %1$s: product name, %2$s: deactivate url */
$message = sprintf( __( 'Subscription for %1$s deactivated successfully. You will no longer receive updates for this product. <a href="%2$s">Click here</a> if you wish to deactive the plugin as well.', 'woocommerce' ),
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>', esc_url( $deactivate_plugin_url ) );
}
$notices[] = array(
@ -203,44 +212,50 @@ class WC_Helper {
case 'deactivate-error':
$subscription = self::_get_subscription_from_product_id( absint( $_GET['wc-helper-product-id'] ) );
$notices[] = array(
'message' => sprintf( 'An error has occurred when deactivating the subscription for <strong>%s</strong>. Please try again later.', esc_html( $subscription['product_name'] ) ),
'type' => 'error',
/* translators: %s: product name */
'message' => sprintf( __( 'An error has occurred when deactivating the subscription for %s. Please try again later.', 'woocommerce' ),
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>' ),
);
break;
case 'deactivate-plugin-success':
$subscription = self::_get_subscription_from_product_id( absint( $_GET['wc-helper-product-id'] ) );
$notices[] = array(
'message' => sprintf( 'The extension <strong>%s</strong> has been deactivated successfully.', esc_html( $subscription['product_name'] ) ),
'type' => 'updated',
/* translators: %s: product name */
'message' => sprintf( __( 'The extension %s has been deactivated successfully.', 'woocommerce' ),
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>' ),
);
break;
case 'deactivate-plugin-error':
$subscription = self::_get_subscription_from_product_id( absint( $_GET['wc-helper-product-id'] ) );
$notices[] = array(
'message' => sprintf( 'An error has occurred when deactivating the extension <strong>%1$s</strong>. Please proceed to the <a href="%2$s">Plugins screen</a> to deactivate it manually.', esc_html( $subscription['product_name'] ), admin_url( 'plugins.php' ) ),
'type' => 'error',
/* translators: %1$s: product name, %2$s: plugins screen url */
'message' => sprintf( __( 'An error has occurred when deactivating the extension %1$s. Please proceed to the <a href="%2$s">Plugins screen</a> to deactivate it manually.', 'woocommerce' ),
'<strong>' . esc_html( $subscription['product_name'] ) . '</strong>', admin_url( 'plugins.php' ) ),
);
break;
case 'helper-connected':
$notices[] = array(
'message' => 'You have successfully connected your store to WooCommerce.com',
'message' => __( 'You have successfully connected your store to WooCommerce.com', 'woocommerce' ),
'type' => 'updated',
);
break;
case 'helper-disconnected':
$notices[] = array(
'message' => 'You have successfully disconnected your store from WooCommerce.com',
'message' => __( 'You have successfully disconnected your store from WooCommerce.com', 'woocommerce' ),
'type' => 'updated',
);
break;
case 'helper-refreshed':
$notices[] = array(
'message' => 'Authentication and subscription caches refreshed successfully.',
'message' => __( 'Authentication and subscription caches refreshed successfully.', 'woocommerce' ),
'type' => 'updated',
);
break;

View File

@ -6,16 +6,16 @@
<?php include( WC_Helper::get_view_filename( 'html-section-notices.php' ) ); ?>
<?php include( WC_Helper::get_view_filename( 'html-section-account.php' ) ); ?>
<h2>Subscriptions</h2>
<p>Below is a list of products available on your WooCommerce.com account. To receive plugin updates please make sure the product is installed, activated and connected to your WooCommerce.com account.</p>
<h2><?php _e( 'Subscriptions', 'woocommerce' ); ?></h2>
<p><?php _e( 'Below is a list of products available on your WooCommerce.com account. To receive plugin updates please make sure the product is installed, activated and connected to your WooCommerce.com account.', 'woocommerce' ); ?></p>
<table class="wp-list-table widefat fixed striped ">
<thead>
<tr>
<th>Product</th>
<th>Subscription</th>
<th>Site usage</th>
<th>Action</th>
<th><?php _e( 'Product', 'woocommerce' ); ?></th>
<th><?php _e( 'Subscription', 'woocommerce' ); ?></th>
<th><?php _e( 'Site Usage', 'woocommerce' ); ?></th>
<th><?php _e( 'Action', 'woocommerce' ); ?></th>
</tr>
</thead>
<?php if ( ! empty( $subscriptions ) ) : ?>
@ -55,35 +55,39 @@
<a class="product-name" href="<?php echo esc_url( $subscription['product_url'] ); ?>" target="_blank"><?php
echo esc_html( $subscription['product_name'] ); ?></a><br>
<?php if ( $update_available && $connected && ! $subscription['expired'] ) : ?>
<a href="<?php echo admin_url( 'update-core.php' ); ?>">Update to <?php echo esc_html( $updates[ $product_id ]['version'] ); ?></a>
<?php /* translators: %s: version number */ ?>
<a href="<?php echo admin_url( 'update-core.php' ); ?>"><?php printf( __( 'Update to %s', 'woocommerce' ), esc_html( $updates[ $product_id ]['version'] ) ); ?></a>
<?php endif; ?>
<?php if ( $update_available && $connected && $subscription['expired'] ) : ?>
<?php echo esc_html( $updates[ $product_id ]['version'] ); ?> available
<?php /* translators: %s: version number */ ?>
<?php printf( __( '%s available', 'woocommerce' ), esc_html( $updates[ $product_id ]['version'] ) ); ?>
<a href="#">[?]</a><!-- Sub is active but expired -->
<?php endif; ?>
<?php if ( $update_available && ! $connected ) : ?>
<?php echo esc_html( $updates[ $product_id ]['version'] ); ?> available
<?php /* translators: %s: version number */ ?>
<?php printf( __( '%s available', 'woocommerce' ), esc_html( $updates[ $product_id ]['version'] ) ); ?>
<a href="#">[?]</a><!-- Subscription must be active to receive updates -->
<?php endif; ?>
<?php if ( ! $installed ) : ?>
<strong><?php echo $updates[ $product_id ]['version']; ?> available</a></strong>
<?php /* translators: %s: version number */ ?>
<strong><?php printf( __( '%s available', 'woocommerce' ), esc_html( $updates[ $product_id ]['version'] ) ); ?></strong>
<?php endif; ?>
</td>
<td>
<?php if ( $subscription['expired'] ) : ?>
<strong><span class="expired" style="color: #B81C23;">Expired :(</span></strong><br>
<strong><span class="expired" style="color: #B81C23;"><?php _e( 'Expired :(', 'woocommerce' ); ?></span></strong><br>
<strong><?php echo date( 'F jS, Y', $subscription['expires'] ); ?></strong>
<?php elseif ( $subscription['autorenew'] ) : ?>
<span class="renews" style="color: black;">Auto renews on:</span><br>
<span class="renews" style="color: black;"><?php _e( 'Auto renews on:', 'woocommerce' ); ?></span><br>
<span><?php echo date( 'F jS, Y', $subscription['expires'] ); ?></span>
<?php elseif ( $subscription['expiring'] ) : ?>
<strong><span class="expiring" style="color: orange;">Expiring soon!</span></strong><br>
<strong><span class="expiring" style="color: orange;"><?php _e( 'Expiring soon!', 'woocommerce' ); ?></span></strong><br>
<strong><?php echo date( 'F jS, Y', $subscription['expires'] ); ?></strong>
<?php else : ?>
<span class="renews" style="color: black;">Expires on:</span><br>
<span class="renews" style="color: black;"><?php _e( 'Expires on:', 'woocommerce' ); ?></span><br>
<span><?php echo date( 'F jS, Y', $subscription['expires'] ); ?></span>
<?php endif; ?>
</td>
@ -91,34 +95,35 @@
<?php echo esc_html( $subscription['key_type_label'] ); ?>
<?php
if ( $subscription['sites_max'] > 0 ) {
printf( '(%d of %d used)', $subscription['sites_active'], $subscription['sites_max'] );
/* translators: %1$d: sites active, %2$d max sites active */
printf( __( '(%1$d of %2$d used)', 'woocommerce' ), $subscription['sites_active'], $subscription['sites_max'] );
}
?><br>
<?php if ( ! $installed ) : ?>
Not installed<br>
<?php _e( 'Not installed', 'woocommerce' ); ?><br>
<?php elseif ( $installed ) : ?>
Installed on this site<br>
<?php _e( 'Installed on this site', 'woocommerce' ); ?><br>
<?php endif; ?>
</td>
<td>
<?php if ( ! $subscription['expired'] ) : ?>
<?php if ( $connected ) : ?>
<?php if ( $update_available ) : ?>
<a class="button" href="<?php echo admin_url( 'update-core.php' ); ?>">Update</a>
<a class="button" href="<?php echo admin_url( 'update-core.php' ); ?>"><?php _e( 'Update', 'woocommerce' ); ?></a>
<?php endif; ?>
<?php if ( $subscription['expiring'] ) : ?>
<a class="button" href="https://woocommerce.com/my-account/my-subscriptions/">Renew</a>
<a class="button" href="https://woocommerce.com/my-account/my-subscriptions/"><?php _e( 'Renew', 'woocommerce' ); ?></a>
<?php endif; ?>
<a class="button" href="<?php echo esc_url( $subscription['deactivate_url'] ); ?>">Deactivate</a>
<a class="button" href="<?php echo esc_url( $subscription['deactivate_url'] ); ?>"><?php _e( 'Deactivate', 'woocommerce' ); ?></a>
<?php elseif ( $subscription['expiring'] ) : ?>
<a class="button" href="https://woocommerce.com/my-account/my-subscriptions/">Renew</a>
<a class="button" href="https://woocommerce.com/my-account/my-subscriptions/"><?php _e( 'Renew', 'woocommerce' ); ?></a>
<?php elseif ( $installed ) : ?>
<a class="button" href="<?php echo esc_url( $subscription['activate_url'] ); ?>">Activate</a>
<a class="button" href="<?php echo esc_url( $subscription['activate_url'] ); ?>"><?php _e( 'Activate', 'woocommerce' ); ?></a>
<?php else : ?>
<a class="button" href="<?php echo esc_url( $download_url ); ?>" target="_blank">Download</a>
<a class="button" href="<?php echo esc_url( $download_url ); ?>" target="_blank"><?php _e( 'Download', 'woocommerce' ); ?></a>
<?php endif; ?>
<?php else : ?>
<a class="button" href="https://woocommerce.com/my-account/my-subscriptions/" target="_blank">Renew</a>
<a class="button" href="https://woocommerce.com/my-account/my-subscriptions/" target="_blank"><?php _e( 'Renew', 'woocommerce' ); ?></a>
<?php endif; ?>
</td>
</tr>
@ -126,20 +131,20 @@
<?php endforeach; ?>
<?php else : ?>
<tr>
<td colspan="3"><em>Could not find any subscriptions on your WooCommerce.com account</td>
<td colspan="3"><em><?php _e( 'Could not find any subscriptions on your WooCommerce.com account', 'woocommerce' ); ?></td>
</tr>
<?php endif; ?>
</table>
<?php if ( ! empty( $no_subscriptions ) ) : ?>
<h2>Installed Extensions Without a Subscription</h2>
<h2><?php _e( 'Installed Extensions Without a Subscription', 'woocommerce' ); ?></h2>
<table class="wp-list-table widefat fixed striped ">
<thead>
<tr>
<th>Product</th>
<th>Subscription</th>
<th><?php _e( 'Product', 'woocommerce' ); ?></th>
<th><?php _e( 'Subscription', 'woocommerce' ); ?></th>
<th></th>
<th>Action</th>
<th><?php _e( 'Action', 'woocommerce' ); ?></th>
</tr>
</thead>
@ -163,23 +168,24 @@
?>
<tr>
<td>
<?php echo esc_html( $data['Name'] ); ?><br>
<?php echo esc_html( $data['Version'] ); ?> installed
<?php /* translators: %1$s: product name, %2$s: product version */ ?>
<?php printf( __( '%1$s<br>%1$s installed', 'woocommerce' ), esc_html( $data['Name'] ), esc_html( $data['Version'] ) ); ?>
<?php if ( ! $update_available ) : ?>
(latest)
<?php _e( '(latest)', 'woocommerce' ); ?>
<?php endif; ?>
<br>
<?php if ( $update_available ) : ?>
<strong><?php echo esc_html( $updates[ $product_id ]['version'] ); ?> available</strong>
<?php /* translators: %s: version number */ ?>
<strong><?php printf( __( '%s available', 'woocommerce' ), esc_html( $updates[ $product_id ]['version'] ) ); ?></strong>
<a href="#">[?]</a><!-- There must be an active subscription to receive updates -->
<?php endif; ?>
</td>
<td>No/Invalid subscription</td>
<td><?php _e( 'No/Invalid subscription', 'woocommerce' ); ?></td>
<td></td>
<td>
<a class="button" href="<?php echo esc_url( $product_url ); ?>" target="_blank">Purchase Subscription</a>
<a class="button" href="<?php echo esc_url( $product_url ); ?>" target="_blank"><?php _e( 'Purchase Subscription', 'woocommerce' ); ?></a>
</td>
</tr>
<?php endforeach; ?>

View File

@ -9,12 +9,12 @@
<img src="https://woocommerce.com/wp-content/themes/woomattic/images/logo-woocommerce@2x.png" alt="WooCommerce" style="width:180px;">
<?php if ( ! empty( $_GET['wc-helper-status'] ) && $_GET['wc-helper-status'] = 'helper-disconnected' ) : ?>
<p><strong>Sorry to see you go</strong>. Feel free to reconnect again using the button below.</p>
<p><?php _e( '<strong>Sorry to see you go</strong>. Feel free to reconnect again using the button below.', 'woocommerce' ); ?></p>
<?php endif; ?>
<h2><?php _e( 'Connect your store to your WooCommerce.com account, and manage your purchases directly from your personal site', 'woocommerce' ); ?></h2>
<p><?php _e( 'When you connect your account, your purchases will automatically be listed on your site. You can disconnect the account at anytime. Once your connected, you will receive the updates &amp; support that come with your subscription. ', 'woocommerce' ); ?></p>
<p><a class="button-primary" href="<?php echo esc_url( $connect_url ); ?>">Connect your store</a></p>
<p><a class="button-primary" href="<?php echo esc_url( $connect_url ); ?>"><?php _e( 'Connect your store', 'woocommerce' ); ?></a></p>
</div>
</div>
</div>

View File

@ -1,15 +1,16 @@
<?php defined( 'ABSPATH' ) or exit(); ?>
<h2>Your Account</h2>
<h2><?php _e( 'Your Account', 'woocommerce' ); ?></h2>
<div class="connect-wrapper">
<div class="connected">
<?php echo get_avatar( $auth_user_data['email'], 100 ); ?>
<p>
<?php printf( 'Connected as:<br /> <strong>%s</strong>', esc_html( $auth_user_data['email'] ) ); ?>
<?php /* translators: %s: connected user e-mail */ ?>
<?php printf( __( 'Connected as:<br /> <strong>%s</strong>', 'woocommerce' ), esc_html( $auth_user_data['email'] ) ); ?>
<span class="buttons">
<a class="button" href="<?php echo esc_url( $refresh_url ); ?>">Refresh</a>
<a class="button" href="<?php echo esc_url( $disconnect_url ); ?>">Disconnect</a>
<a class="button" href="<?php echo esc_url( $refresh_url ); ?>"><?php _e( 'Refresh', 'woocommerce' ); ?></a>
<a class="button" href="<?php echo esc_url( $disconnect_url ); ?>"><?php _e( 'Disconnect', 'woocommerce' ); ?></a>
</span>
</p>
</div>