Update weight/dim formatting to use translated labels
This commit is contained in:
parent
21bae97e82
commit
45069b1bf7
|
@ -8,6 +8,7 @@
|
||||||
* @version 2.1.0
|
* @version 2.1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Automattic\WooCommerce\Utilities\I18nUtil;
|
||||||
use Automattic\WooCommerce\Utilities\NumberUtil;
|
use Automattic\WooCommerce\Utilities\NumberUtil;
|
||||||
|
|
||||||
defined( 'ABSPATH' ) || exit;
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
@ -1303,7 +1304,14 @@ function wc_format_weight( $weight ) {
|
||||||
$weight_string = wc_format_localized_decimal( $weight );
|
$weight_string = wc_format_localized_decimal( $weight );
|
||||||
|
|
||||||
if ( ! empty( $weight_string ) ) {
|
if ( ! empty( $weight_string ) ) {
|
||||||
$weight_string .= ' ' . get_option( 'woocommerce_weight_unit' );
|
$weight_label = I18nUtil::get_weight_unit_label( get_option( 'woocommerce_weight_unit' ) );
|
||||||
|
|
||||||
|
$weight_string = sprintf(
|
||||||
|
// translators: 1. A formatted number; 2. A label for a weight unit of measure. E.g. 2.72 kg
|
||||||
|
_x( '%1$s %2$s', 'formatted weight', 'woocommerce' ),
|
||||||
|
$weight_string,
|
||||||
|
$weight_label
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$weight_string = __( 'N/A', 'woocommerce' );
|
$weight_string = __( 'N/A', 'woocommerce' );
|
||||||
}
|
}
|
||||||
|
@ -1322,7 +1330,14 @@ function wc_format_dimensions( $dimensions ) {
|
||||||
$dimension_string = implode( ' × ', array_filter( array_map( 'wc_format_localized_decimal', $dimensions ) ) );
|
$dimension_string = implode( ' × ', array_filter( array_map( 'wc_format_localized_decimal', $dimensions ) ) );
|
||||||
|
|
||||||
if ( ! empty( $dimension_string ) ) {
|
if ( ! empty( $dimension_string ) ) {
|
||||||
$dimension_string .= ' ' . get_option( 'woocommerce_dimension_unit' );
|
$dimension_label = I18nUtil::get_dimensions_unit_label( get_option( 'woocommerce_dimension_unit' ) );
|
||||||
|
|
||||||
|
$dimension_string = sprintf(
|
||||||
|
// translators: 1. A formatted number; 2. A label for a dimensions unit of measure. E.g. 3.14 cm
|
||||||
|
_x( '%1$s %2$s', 'formatted dimensions', 'woocommerce' ),
|
||||||
|
$dimension_string,
|
||||||
|
$dimension_label
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$dimension_string = __( 'N/A', 'woocommerce' );
|
$dimension_string = __( 'N/A', 'woocommerce' );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue