i18n Improvements (#12078)
* use %s in translations strings
* merge simmilar error strings
* i18n: use sprintf() in translation strings to make them easier to understand for translators
* i18n: remove sprintf() function from translation string with unused parameter
* i18n: move colons and brackets into the translation strings
* revert comit addaa5d
* Fix broken sprintf()
* i18n: move colons into the translation strings on error messages
* Fix Travis-CI Error: operator must be surrounded by a single space
This commit is contained in:
parent
4375618438
commit
f27499b501
|
@ -1189,7 +1189,7 @@ class WC_Product {
|
|||
|
||||
$rating_html = '<div class="star-rating" title="' . sprintf( __( 'Rated %s out of 5', 'woocommerce' ), $rating ) . '">';
|
||||
|
||||
$rating_html .= '<span style="width:' . ( ( $rating / 5 ) * 100 ) . '%"><strong class="rating">' . $rating . '</strong> ' . __( 'out of 5', 'woocommerce' ) . '</span>';
|
||||
$rating_html .= '<span style="width:' . ( ( $rating / 5 ) * 100 ) . '%">' . sprintf( __( '%s out of 5', 'woocommerce' ), '<strong class="rating">' . $rating . '</strong>' ) . '</span>';
|
||||
|
||||
$rating_html .= '</div>';
|
||||
}
|
||||
|
|
|
@ -189,9 +189,9 @@ class WC_Admin_Dashboard {
|
|||
$rating = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) );
|
||||
|
||||
echo '<div class="star-rating" title="' . esc_attr( $rating ) . '">
|
||||
<span style="width:' . ( $rating * 20 ) . '%">' . $rating . ' ' . __( 'out of 5', 'woocommerce' ) . '</span></div>';
|
||||
<span style="width:' . ( $rating * 20 ) . '%">' . sprintf( __( '%s out of 5', 'woocommerce' ), $rating ) . '</span></div>';
|
||||
|
||||
echo '<h4 class="meta"><a href="' . get_permalink( $comment->ID ) . '#comment-' . absint( $comment->comment_ID ) . '">' . esc_html( apply_filters( 'woocommerce_admin_dashboard_recent_reviews', $comment->post_title, $comment ) ) . '</a> ' . __( 'reviewed by', 'woocommerce' ) . ' ' . esc_html( $comment->comment_author ) . '</h4>';
|
||||
echo '<h4 class="meta"><a href="' . get_permalink( $comment->ID ) . '#comment-' . absint( $comment->comment_ID ) . '">' . esc_html( apply_filters( 'woocommerce_admin_dashboard_recent_reviews', $comment->post_title, $comment ) ) . '</a> ' . sprintf( __( 'reviewed by %s', 'woocommerce' ), esc_html( $comment->comment_author ) ) . '</h4>';
|
||||
echo '<blockquote>' . wp_kses_data( $comment->comment_excerpt ) . ' [...]</blockquote></li>';
|
||||
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ class WC_Admin_Duplicate_Product {
|
|||
wp_redirect( admin_url( 'post.php?action=edit&post=' . $new_id ) );
|
||||
exit;
|
||||
} else {
|
||||
wp_die( __( 'Product creation failed, could not find original product:', 'woocommerce' ) . ' ' . $id );
|
||||
wp_die( sprintf( __( 'Product creation failed, could not find original product: %s', 'woocommerce' ), $id ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -676,7 +676,7 @@ class WC_Meta_Box_Product_Data {
|
|||
$variation_selected_value = isset( $default_attributes[ sanitize_title( $attribute['name'] ) ] ) ? $default_attributes[ sanitize_title( $attribute['name'] ) ] : '';
|
||||
|
||||
// Name will be something like attribute_pa_color
|
||||
echo '<select name="default_attribute_' . sanitize_title( $attribute['name'] ) . '" data-current="' . esc_attr( $variation_selected_value ) . '"><option value="">' . __( 'No default', 'woocommerce' ) . ' ' . esc_html( wc_attribute_label( $attribute['name'] ) ) . '…</option>';
|
||||
echo '<select name="default_attribute_' . sanitize_title( $attribute['name'] ) . '" data-current="' . esc_attr( $variation_selected_value ) . '"><option value="">' . sprintf( __( 'No default %s…', 'woocommerce' ), esc_html( wc_attribute_label( $attribute['name'] ) ) ) . '</option>';
|
||||
|
||||
// Get terms for attribute taxonomy or value if its a custom attribute
|
||||
if ( $attribute['is_taxonomy'] ) {
|
||||
|
|
|
@ -126,7 +126,7 @@ if ( wc_tax_enabled() ) {
|
|||
?>
|
||||
<table class="wc-order-totals">
|
||||
<tr>
|
||||
<td class="label"><?php echo wc_help_tip( __( 'This is the total discount. Discounts are defined per line item.', 'woocommerce' ) ); ?> <?php _e( 'Discount', 'woocommerce' ); ?>:</td>
|
||||
<td class="label"><?php echo wc_help_tip( __( 'This is the total discount. Discounts are defined per line item.', 'woocommerce' ) ); ?> <?php _e( 'Discount:', 'woocommerce' ); ?></td>
|
||||
<td width="1%"></td>
|
||||
<td class="total">
|
||||
<?php echo wc_price( $order->get_total_discount(), array( 'currency' => $order->get_currency() ) ); ?>
|
||||
|
@ -136,7 +136,7 @@ if ( wc_tax_enabled() ) {
|
|||
<?php do_action( 'woocommerce_admin_order_totals_after_discount', $order->get_id() ); ?>
|
||||
|
||||
<tr>
|
||||
<td class="label"><?php echo wc_help_tip( __( 'This is the shipping and handling total costs for the order.', 'woocommerce' ) ); ?> <?php _e( 'Shipping', 'woocommerce' ); ?>:</td>
|
||||
<td class="label"><?php echo wc_help_tip( __( 'This is the shipping and handling total costs for the order.', 'woocommerce' ) ); ?> <?php _e( 'Shipping:', 'woocommerce' ); ?></td>
|
||||
<td width="1%"></td>
|
||||
<td class="total"><?php
|
||||
if ( ( $refunded = $order->get_total_shipping_refunded() ) > 0 ) {
|
||||
|
@ -257,7 +257,7 @@ if ( wc_tax_enabled() ) {
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label"><label for="refund_reason"><?php echo wc_help_tip( __( 'Note: the refund reason will be visible by the customer.', 'woocommerce' ) ); ?> <?php _e( 'Reason for refund (optional)', 'woocommerce' ); ?>:</label></td>
|
||||
<td class="label"><label for="refund_reason"><?php echo wc_help_tip( __( 'Note: the refund reason will be visible by the customer.', 'woocommerce' ) ); ?> <?php _e( 'Reason for refund (optional):', 'woocommerce' ); ?></label></td>
|
||||
<td class="total">
|
||||
<input type="text" class="text" id="refund_reason" name="refund_reason" />
|
||||
<div class="clear"></div>
|
||||
|
|
|
@ -13,7 +13,7 @@ $who_refunded = new WP_User( $refund->get_refunded_by() );
|
|||
|
||||
<td class="name">
|
||||
<?php
|
||||
echo esc_attr__( 'Refund', 'woocommerce' ) . ' #' . $refund->get_id() . ' - ' . esc_attr( date_i18n( get_option( 'date_format' ) . ', ' . get_option( 'time_format' ), $refund->get_date_created() ) );
|
||||
printf( __( 'Refund #%1$s - %2$s', 'woocommerce' ), $refund->get_id(), date_i18n( get_option( 'date_format' ) . ', ' . get_option( 'time_format' ), $refund->get_date_created() ) );
|
||||
|
||||
if ( $who_refunded->exists() ) {
|
||||
echo ' ' . esc_attr_x( 'by', 'Ex: Refund - $date >by< $username', 'woocommerce' ) . ' ' . '<abbr class="refund_by" title="' . sprintf( esc_attr__( 'ID: %d', 'woocommerce' ), absint( $who_refunded->ID ) ) . '">' . esc_attr( $who_refunded->display_name ) . '</abbr>' ;
|
||||
|
|
|
@ -30,7 +30,7 @@ extract( $variation_data );
|
|||
$variation_selected_value = isset( $variation_data[ 'attribute_' . sanitize_title( $attribute['name'] ) ] ) ? $variation_data[ 'attribute_' . sanitize_title( $attribute['name'] ) ] : '';
|
||||
|
||||
// Name will be something like attribute_pa_color
|
||||
echo '<select name="attribute_' . sanitize_title( $attribute['name'] ) . '[' . $loop . ']"><option value="">' . __( 'Any', 'woocommerce' ) . ' ' . esc_html( wc_attribute_label( $attribute['name'] ) ) . '…</option>';
|
||||
echo '<select name="attribute_' . sanitize_title( $attribute['name'] ) . '[' . $loop . ']"><option value="">' . sprintf( __( 'Any %s…', 'woocommerce' ), esc_html( wc_attribute_label( $attribute['name'] ) ) ) . '</option>';
|
||||
|
||||
// Get terms for attribute taxonomy or value if its a custom attribute
|
||||
if ( $attribute['is_taxonomy'] ) {
|
||||
|
@ -170,7 +170,7 @@ extract( $variation_data );
|
|||
<div>
|
||||
<?php if ( wc_product_weight_enabled() ) : ?>
|
||||
<p class="form-row hide_if_variation_virtual form-row-first">
|
||||
<label><?php printf( __( 'Weight (%s)', 'woocommerce' ), get_option( 'woocommerce_weight_unit' ) ); ?> <?php echo wc_help_tip( __( 'Enter a weight for this variation or leave blank to use the parent product weight.', 'woocommerce' ) ); ?></a></label>
|
||||
<label><?php printf( __( 'Weight (%s)', 'woocommerce' ), esc_html( get_option( 'woocommerce_weight_unit' ) ) ); ?> <?php echo wc_help_tip( __( 'Enter a weight for this variation or leave blank to use the parent product weight.', 'woocommerce' ) ); ?></a></label>
|
||||
<input type="text" size="5" name="variable_weight[<?php echo $loop; ?>]" value="<?php if ( isset( $_weight ) ) echo esc_attr( $_weight ); ?>" placeholder="<?php echo esc_attr( $parent_data['weight'] ); ?>" class="wc_input_decimal" />
|
||||
</p>
|
||||
<?php else : ?>
|
||||
|
|
|
@ -98,7 +98,7 @@ class WC_Form_Handler {
|
|||
|
||||
// Validation: Required fields.
|
||||
if ( ! empty( $field['required'] ) && empty( $_POST[ $key ] ) ) {
|
||||
wc_add_notice( $field['label'] . ' ' . __( 'is a required field.', 'woocommerce' ), 'error' );
|
||||
wc_add_notice( sprintf( __( '%s is a required field.', 'woocommerce' ), $field['label'] ), 'error' );
|
||||
}
|
||||
|
||||
if ( ! empty( $_POST[ $key ] ) ) {
|
||||
|
@ -120,14 +120,14 @@ class WC_Form_Handler {
|
|||
$_POST[ $key ] = wc_format_phone_number( $_POST[ $key ] );
|
||||
|
||||
if ( ! WC_Validation::is_phone( $_POST[ $key ] ) ) {
|
||||
wc_add_notice( '<strong>' . $field['label'] . '</strong> ' . __( 'is not a valid phone number.', 'woocommerce' ), 'error' );
|
||||
wc_add_notice( sprintf( __( '%s is not a valid phone number.', 'woocommerce' ), $field['label'] ), 'error' );
|
||||
}
|
||||
break;
|
||||
case 'email' :
|
||||
$_POST[ $key ] = strtolower( $_POST[ $key ] );
|
||||
|
||||
if ( ! is_email( $_POST[ $key ] ) ) {
|
||||
wc_add_notice( '<strong>' . $field['label'] . '</strong> ' . __( 'is not a valid email address.', 'woocommerce' ), 'error' );
|
||||
wc_add_notice( sprintf( __( '%s is not a valid email address.', 'woocommerce' ), $field['label'] ), 'error' );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ class WC_Form_Handler {
|
|||
|
||||
foreach ( $required_fields as $field_key => $field_name ) {
|
||||
if ( empty( $_POST[ $field_key ] ) ) {
|
||||
wc_add_notice( '<strong>' . esc_html( $field_name ) . '</strong> ' . __( 'is a required field.', 'woocommerce' ), 'error' );
|
||||
wc_add_notice( sprintf( __( '%s is a required field.', 'woocommerce' ), esc_html( $field_name ) ), 'error' );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -879,15 +879,15 @@ class WC_Form_Handler {
|
|||
$validation_error = apply_filters( 'woocommerce_process_login_errors', $validation_error, $_POST['username'], $_POST['password'] );
|
||||
|
||||
if ( $validation_error->get_error_code() ) {
|
||||
throw new Exception( '<strong>' . __( 'Error', 'woocommerce' ) . ':</strong> ' . $validation_error->get_error_message() );
|
||||
throw new Exception( '<strong>' . __( 'Error:', 'woocommerce' ) . '</strong> ' . $validation_error->get_error_message() );
|
||||
}
|
||||
|
||||
if ( empty( $username ) ) {
|
||||
throw new Exception( '<strong>' . __( 'Error', 'woocommerce' ) . ':</strong> ' . __( 'Username is required.', 'woocommerce' ) );
|
||||
throw new Exception( '<strong>' . __( 'Error:', 'woocommerce' ) . '</strong> ' . __( 'Username is required.', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
if ( empty( $_POST['password'] ) ) {
|
||||
throw new Exception( '<strong>' . __( 'Error', 'woocommerce' ) . ':</strong> ' . __( 'Password is required.', 'woocommerce' ) );
|
||||
throw new Exception( '<strong>' . __( 'Error:', 'woocommerce' ) . '</strong> ' . __( 'Password is required.', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
if ( is_email( $username ) && apply_filters( 'woocommerce_get_username_from_email', true ) ) {
|
||||
|
@ -896,7 +896,7 @@ class WC_Form_Handler {
|
|||
if ( isset( $user->user_login ) ) {
|
||||
$creds['user_login'] = $user->user_login;
|
||||
} else {
|
||||
throw new Exception( '<strong>' . __( 'Error', 'woocommerce' ) . ':</strong> ' . __( 'A user could not be found with this email address.', 'woocommerce' ) );
|
||||
throw new Exception( '<strong>' . __( 'Error:', 'woocommerce' ) . '</strong> ' . __( 'A user could not be found with this email address.', 'woocommerce' ) );
|
||||
}
|
||||
} else {
|
||||
$creds['user_login'] = $username;
|
||||
|
@ -1037,7 +1037,7 @@ class WC_Form_Handler {
|
|||
exit;
|
||||
|
||||
} catch ( Exception $e ) {
|
||||
wc_add_notice( '<strong>' . __( 'Error', 'woocommerce' ) . ':</strong> ' . $e->getMessage(), 'error' );
|
||||
wc_add_notice( '<strong>' . __( 'Error:', 'woocommerce' ) . '</strong> ' . $e->getMessage(), 'error' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,9 +68,13 @@ class WC_Payment_Token_CC extends WC_Payment_Token {
|
|||
* @return string
|
||||
*/
|
||||
public function get_display_name() {
|
||||
$display = wc_get_credit_card_type_label( $this->get_card_type() );
|
||||
$display .= ' ' . sprintf( __( 'ending in %s', 'woocommerce' ), $this->get_last4() );
|
||||
$display .= ' ' . sprintf( __( '(expires %s)', 'woocommerce' ), $this->get_expiry_month() . '/' . substr( $this->get_expiry_year(), 2 ) );
|
||||
$display = sprintf(
|
||||
__( '%1$s ending in %2$s (expires %3$s/%4$s)', 'woocommerce' ),
|
||||
wc_get_credit_card_type_label( $this->get_card_type() ),
|
||||
$this->get_last4(),
|
||||
$this->get_expiry_month(),
|
||||
substr( $this->get_expiry_year(), 2 )
|
||||
);
|
||||
return $display;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ class WC_Shortcode_Order_Tracking {
|
|||
}
|
||||
} else {
|
||||
|
||||
echo '<p class="woocommerce-error">' . sprintf( __( 'Sorry, we could not find that order ID in our database.', 'woocommerce' ), get_permalink( $post->ID ) ) . '</p>';
|
||||
echo '<p class="woocommerce-error">' . __( 'Sorry, we could not find that order ID in our database.', 'woocommerce' ) . '</p>';
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ function wc_cart_totals_coupon_label( $coupon, $echo = true ) {
|
|||
$coupon = new WC_Coupon( $coupon );
|
||||
}
|
||||
|
||||
$label = apply_filters( 'woocommerce_cart_totals_coupon_label', esc_html( __( 'Coupon:', 'woocommerce' ) . ' ' . $coupon->get_code() ), $coupon );
|
||||
$label = apply_filters( 'woocommerce_cart_totals_coupon_label', sprintf( esc_html__( 'Coupon: %s', 'woocommerce' ), $coupon->get_code() ), $coupon );
|
||||
|
||||
if ( $echo ) {
|
||||
echo $label;
|
||||
|
|
|
@ -108,7 +108,7 @@ if ( ! function_exists( 'wc_create_new_customer' ) ) {
|
|||
$customer_id = wp_insert_user( $new_customer_data );
|
||||
|
||||
if ( is_wp_error( $customer_id ) ) {
|
||||
return new WP_Error( 'registration-error', '<strong>' . __( 'ERROR', 'woocommerce' ) . '</strong>: ' . __( 'Couldn’t register you… please contact us if you continue to have problems.', 'woocommerce' ) );
|
||||
return new WP_Error( 'registration-error', '<strong>' . __( 'Error:', 'woocommerce' ) . '</strong> ' . __( 'Couldn’t register you… please contact us if you continue to have problems.', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_created_customer', $customer_id, $new_customer_data, $password_generated );
|
||||
|
|
|
@ -68,7 +68,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
<?php if ( wc_tax_enabled() && 'excl' === WC()->cart->tax_display_cart ) :
|
||||
$taxable_address = WC()->customer->get_taxable_address();
|
||||
$estimated_text = WC()->customer->is_customer_outside_base() && ! WC()->customer->has_calculated_shipping()
|
||||
? sprintf( ' <small>(' . __( 'estimated for %s', 'woocommerce' ) . ')</small>', WC()->countries->estimated_for_prefix( $taxable_address[0] ) . WC()->countries->countries[ $taxable_address[0] ] )
|
||||
? sprintf( ' <small>' . __( '(estimated for %s)', 'woocommerce' ) . '</small>', WC()->countries->estimated_for_prefix( $taxable_address[0] ) . WC()->countries->countries[ $taxable_address[0] ] )
|
||||
: '';
|
||||
|
||||
if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
|
||||
|
|
|
@ -35,7 +35,11 @@ if ( $rating_count > 0 ) : ?>
|
|||
<div class="woocommerce-product-rating">
|
||||
<div class="star-rating" title="<?php printf( __( 'Rated %s out of 5', 'woocommerce' ), $average ); ?>">
|
||||
<span style="width:<?php echo ( ( $average / 5 ) * 100 ); ?>%">
|
||||
<strong class="rating"><?php echo esc_html( $average ); ?></strong> <?php printf( __( 'out of %1$s5%2$s', 'woocommerce' ), '<span>', '</span>' ); ?>
|
||||
<?php printf(
|
||||
__( '%1$s out of %2$s', 'woocommerce' ),
|
||||
'<strong class="rating">' . esc_html( $average ) . '</strong>',
|
||||
'<span>5</span>'
|
||||
); ?>
|
||||
<?php printf( _n( 'based on %s customer rating', 'based on %s customer ratings', $rating_count, 'woocommerce' ), '<span class="rating">' . $rating_count . '</span>' ); ?>
|
||||
</span>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue