diff --git a/plugins/woocommerce/includes/admin/importers/class-wc-product-csv-importer-controller.php b/plugins/woocommerce/includes/admin/importers/class-wc-product-csv-importer-controller.php index a2e69186818..485d6f6ef68 100644 --- a/plugins/woocommerce/includes/admin/importers/class-wc-product-csv-importer-controller.php +++ b/plugins/woocommerce/includes/admin/importers/class-wc-product-csv-importer-controller.php @@ -5,6 +5,8 @@ * @package WooCommerce\Admin\Importers */ +use Automattic\WooCommerce\Utilities\I18nUtil; + if ( ! defined( 'ABSPATH' ) ) { exit; } @@ -482,8 +484,8 @@ class WC_Product_CSV_Importer_Controller { * @return array */ protected function auto_map_columns( $raw_headers, $num_indexes = true ) { - $weight_unit = get_option( 'woocommerce_weight_unit' ); - $dimension_unit = get_option( 'woocommerce_dimension_unit' ); + $weight_unit_label = I18nUtil::get_weight_unit_label( get_option( 'woocommerce_weight_unit', 'kg' ) ); + $dimension_unit_label = I18nUtil::get_dimensions_unit_label( get_option( 'woocommerce_dimension_unit', 'cm' ) ); /* * @hooked wc_importer_generic_mappings - 10 @@ -513,13 +515,13 @@ class WC_Product_CSV_Importer_Controller { __( 'Low stock amount', 'woocommerce' ) => 'low_stock_amount', __( 'Sold individually?', 'woocommerce' ) => 'sold_individually', /* translators: %s: Weight unit */ - sprintf( __( 'Weight (%s)', 'woocommerce' ), $weight_unit ) => 'weight', + sprintf( __( 'Weight (%s)', 'woocommerce' ), $weight_unit_label ) => 'weight', /* translators: %s: Length unit */ - sprintf( __( 'Length (%s)', 'woocommerce' ), $dimension_unit ) => 'length', + sprintf( __( 'Length (%s)', 'woocommerce' ), $dimension_unit_label ) => 'length', /* translators: %s: Width unit */ - sprintf( __( 'Width (%s)', 'woocommerce' ), $dimension_unit ) => 'width', + sprintf( __( 'Width (%s)', 'woocommerce' ), $dimension_unit_label ) => 'width', /* translators: %s: Height unit */ - sprintf( __( 'Height (%s)', 'woocommerce' ), $dimension_unit ) => 'height', + sprintf( __( 'Height (%s)', 'woocommerce' ), $dimension_unit_label ) => 'height', __( 'Allow customer reviews?', 'woocommerce' ) => 'reviews_allowed', __( 'Purchase note', 'woocommerce' ) => 'purchase_note', __( 'Sale price', 'woocommerce' ) => 'sale_price', @@ -655,9 +657,9 @@ class WC_Product_CSV_Importer_Controller { $meta = str_replace( 'meta:', '', $item ); // Available options. - $weight_unit = get_option( 'woocommerce_weight_unit' ); - $dimension_unit = get_option( 'woocommerce_dimension_unit' ); - $options = array( + $weight_unit_label = I18nUtil::get_weight_unit_label( get_option( 'woocommerce_weight_unit', 'kg' ) ); + $dimension_unit_label = I18nUtil::get_dimensions_unit_label( get_option( 'woocommerce_dimension_unit', 'cm' ) ); + $options = array( 'id' => __( 'ID', 'woocommerce' ), 'type' => __( 'Type', 'woocommerce' ), 'sku' => __( 'SKU', 'woocommerce' ), @@ -684,16 +686,16 @@ class WC_Product_CSV_Importer_Controller { 'low_stock_amount' => __( 'Low stock amount', 'woocommerce' ), 'sold_individually' => __( 'Sold individually?', 'woocommerce' ), /* translators: %s: weight unit */ - 'weight' => sprintf( __( 'Weight (%s)', 'woocommerce' ), $weight_unit ), + 'weight' => sprintf( __( 'Weight (%s)', 'woocommerce' ), $weight_unit_label ), 'dimensions' => array( 'name' => __( 'Dimensions', 'woocommerce' ), 'options' => array( /* translators: %s: dimension unit */ - 'length' => sprintf( __( 'Length (%s)', 'woocommerce' ), $dimension_unit ), + 'length' => sprintf( __( 'Length (%s)', 'woocommerce' ), $dimension_unit_label ), /* translators: %s: dimension unit */ - 'width' => sprintf( __( 'Width (%s)', 'woocommerce' ), $dimension_unit ), + 'width' => sprintf( __( 'Width (%s)', 'woocommerce' ), $dimension_unit_label ), /* translators: %s: dimension unit */ - 'height' => sprintf( __( 'Height (%s)', 'woocommerce' ), $dimension_unit ), + 'height' => sprintf( __( 'Height (%s)', 'woocommerce' ), $dimension_unit_label ), ), ), 'category_ids' => __( 'Categories', 'woocommerce' ), diff --git a/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-data-shipping.php b/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-data-shipping.php index 10ba6b29506..6e4b5c3b6f4 100644 --- a/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-data-shipping.php +++ b/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-data-shipping.php @@ -1,4 +1,6 @@ '_weight', 'value' => $product_object->get_weight( 'edit' ), - 'label' => __( 'Weight', 'woocommerce' ) . ' (' . get_option( 'woocommerce_weight_unit' ) . ')', + 'label' => sprintf( + /* translators: %s: Weight unit */ + __( 'Weight (%s)', 'woocommerce' ), + I18nUtil::get_weight_unit_label( get_option( 'woocommerce_weight_unit', 'kg' ) ) + ), 'placeholder' => wc_format_localized_decimal( 0 ), 'desc_tip' => true, 'description' => __( 'Weight in decimal form', 'woocommerce' ), diff --git a/plugins/woocommerce/includes/admin/meta-boxes/views/html-variation-admin.php b/plugins/woocommerce/includes/admin/meta-boxes/views/html-variation-admin.php index 45202b0e407..3ad296f21b4 100644 --- a/plugins/woocommerce/includes/admin/meta-boxes/views/html-variation-admin.php +++ b/plugins/woocommerce/includes/admin/meta-boxes/views/html-variation-admin.php @@ -9,6 +9,8 @@ * @var array $variation_data array of variation data @deprecated 4.4.0. */ +use Automattic\WooCommerce\Utilities\I18nUtil; + defined( 'ABSPATH' ) || exit; ?> @@ -279,9 +281,9 @@ defined( 'ABSPATH' ) || exit; if ( wc_product_weight_enabled() ) { $label = sprintf( - /* translators: %s: weight unit */ + /* translators: %s: Weight unit */ __( 'Weight (%s)', 'woocommerce' ), - esc_html( get_option( 'woocommerce_weight_unit' ) ) + I18nUtil::get_weight_unit_label( get_option( 'woocommerce_weight_unit', 'kg' ) ) ); woocommerce_wp_text_input( diff --git a/plugins/woocommerce/includes/admin/views/html-bulk-edit-product.php b/plugins/woocommerce/includes/admin/views/html-bulk-edit-product.php index 5e81412b5bd..0f182a0f8a7 100644 --- a/plugins/woocommerce/includes/admin/views/html-bulk-edit-product.php +++ b/plugins/woocommerce/includes/admin/views/html-bulk-edit-product.php @@ -3,6 +3,8 @@ * Admin View: Bulk Edit Products */ +use Automattic\WooCommerce\Utilities\I18nUtil; + if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } @@ -131,7 +133,21 @@ if ( ! defined( 'ABSPATH' ) ) { diff --git a/plugins/woocommerce/includes/export/class-wc-product-csv-exporter.php b/plugins/woocommerce/includes/export/class-wc-product-csv-exporter.php index 30f6b096ff5..eff11143cc3 100644 --- a/plugins/woocommerce/includes/export/class-wc-product-csv-exporter.php +++ b/plugins/woocommerce/includes/export/class-wc-product-csv-exporter.php @@ -6,6 +6,8 @@ * @version 3.1.0 */ +use Automattic\WooCommerce\Utilities\I18nUtil; + if ( ! defined( 'ABSPATH' ) ) { exit; } @@ -99,6 +101,9 @@ class WC_Product_CSV_Exporter extends WC_CSV_Batch_Exporter { * @return array */ public function get_default_column_names() { + $weight_unit_label = I18nUtil::get_weight_unit_label( get_option( 'woocommerce_weight_unit', 'kg' ) ); + $dimension_unit_label = I18nUtil::get_dimensions_unit_label( get_option( 'woocommerce_dimension_unit', 'cm' ) ); + return apply_filters( "woocommerce_product_export_{$this->export_type}_default_columns", array( @@ -121,13 +126,13 @@ class WC_Product_CSV_Exporter extends WC_CSV_Batch_Exporter { 'backorders' => __( 'Backorders allowed?', 'woocommerce' ), 'sold_individually' => __( 'Sold individually?', 'woocommerce' ), /* translators: %s: weight */ - 'weight' => sprintf( __( 'Weight (%s)', 'woocommerce' ), get_option( 'woocommerce_weight_unit' ) ), + 'weight' => sprintf( __( 'Weight (%s)', 'woocommerce' ), $weight_unit_label ), /* translators: %s: length */ - 'length' => sprintf( __( 'Length (%s)', 'woocommerce' ), get_option( 'woocommerce_dimension_unit' ) ), + 'length' => sprintf( __( 'Length (%s)', 'woocommerce' ), $dimension_unit_label ), /* translators: %s: width */ - 'width' => sprintf( __( 'Width (%s)', 'woocommerce' ), get_option( 'woocommerce_dimension_unit' ) ), + 'width' => sprintf( __( 'Width (%s)', 'woocommerce' ), $dimension_unit_label ), /* translators: %s: Height */ - 'height' => sprintf( __( 'Height (%s)', 'woocommerce' ), get_option( 'woocommerce_dimension_unit' ) ), + 'height' => sprintf( __( 'Height (%s)', 'woocommerce' ), $dimension_unit_label ), 'reviews_allowed' => __( 'Allow customer reviews?', 'woocommerce' ), 'purchase_note' => __( 'Purchase note', 'woocommerce' ), 'sale_price' => __( 'Sale price', 'woocommerce' ), diff --git a/plugins/woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-products-v1-controller.php b/plugins/woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-products-v1-controller.php index 64e9442e584..276478ccb2b 100644 --- a/plugins/woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-products-v1-controller.php +++ b/plugins/woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-products-v1-controller.php @@ -10,6 +10,8 @@ * @since 3.0.0 */ +use Automattic\WooCommerce\Utilities\I18nUtil; + if ( ! defined( 'ABSPATH' ) ) { exit; } @@ -1728,8 +1730,8 @@ class WC_REST_Products_V1_Controller extends WC_REST_Posts_Controller { * @return array */ public function get_item_schema() { - $weight_unit = get_option( 'woocommerce_weight_unit' ); - $dimension_unit = get_option( 'woocommerce_dimension_unit' ); + $weight_unit_label = I18nUtil::get_weight_unit_label( get_option( 'woocommerce_weight_unit', 'kg' ) ); + $dimension_unit_label = I18nUtil::get_dimensions_unit_label( get_option( 'woocommerce_dimension_unit', 'cm' ) ); $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => $this->post_type, @@ -1985,7 +1987,7 @@ class WC_REST_Products_V1_Controller extends WC_REST_Posts_Controller { ), 'weight' => array( /* translators: %s: weight unit */ - 'description' => sprintf( __( 'Product weight (%s).', 'woocommerce' ), $weight_unit ), + 'description' => sprintf( __( 'Product weight (%s).', 'woocommerce' ), $weight_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), @@ -1996,19 +1998,19 @@ class WC_REST_Products_V1_Controller extends WC_REST_Posts_Controller { 'properties' => array( 'length' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Product length (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Product length (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), 'width' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Product width (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Product width (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), 'height' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Product height (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Product height (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), @@ -2438,7 +2440,7 @@ class WC_REST_Products_V1_Controller extends WC_REST_Posts_Controller { ), 'weight' => array( /* translators: %s: weight unit */ - 'description' => sprintf( __( 'Variation weight (%s).', 'woocommerce' ), $weight_unit ), + 'description' => sprintf( __( 'Variation weight (%s).', 'woocommerce' ), $weight_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), @@ -2449,19 +2451,19 @@ class WC_REST_Products_V1_Controller extends WC_REST_Posts_Controller { 'properties' => array( 'length' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Variation length (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Variation length (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), 'width' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Variation width (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Variation width (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), 'height' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Variation height (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Variation height (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), diff --git a/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-product-variations-v2-controller.php b/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-product-variations-v2-controller.php index 3047e3f9bbf..41ce161f808 100644 --- a/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-product-variations-v2-controller.php +++ b/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-product-variations-v2-controller.php @@ -8,6 +8,8 @@ * @since 3.0.0 */ +use Automattic\WooCommerce\Utilities\I18nUtil; + defined( 'ABSPATH' ) || exit; /** @@ -640,8 +642,8 @@ class WC_REST_Product_Variations_V2_Controller extends WC_REST_Products_V2_Contr * @return array */ public function get_item_schema() { - $weight_unit = get_option( 'woocommerce_weight_unit' ); - $dimension_unit = get_option( 'woocommerce_dimension_unit' ); + $weight_unit_label = I18nUtil::get_weight_unit_label( get_option( 'woocommerce_weight_unit', 'kg' ) ); + $dimension_unit_label = I18nUtil::get_dimensions_unit_label( get_option( 'woocommerce_dimension_unit', 'cm' ) ); $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => $this->post_type, @@ -835,7 +837,7 @@ class WC_REST_Product_Variations_V2_Controller extends WC_REST_Products_V2_Contr ), 'weight' => array( /* translators: %s: weight unit */ - 'description' => sprintf( __( 'Variation weight (%s).', 'woocommerce' ), $weight_unit ), + 'description' => sprintf( __( 'Variation weight (%s).', 'woocommerce' ), $weight_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), @@ -846,19 +848,19 @@ class WC_REST_Product_Variations_V2_Controller extends WC_REST_Products_V2_Contr 'properties' => array( 'length' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Variation length (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Variation length (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), 'width' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Variation width (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Variation width (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), 'height' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Variation height (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Variation height (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), diff --git a/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-products-v2-controller.php b/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-products-v2-controller.php index b85486ece55..b1275bd021d 100644 --- a/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-products-v2-controller.php +++ b/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-products-v2-controller.php @@ -8,6 +8,8 @@ * @since 2.6.0 */ +use Automattic\WooCommerce\Utilities\I18nUtil; + defined( 'ABSPATH' ) || exit; /** @@ -1663,8 +1665,8 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller { * @return array */ public function get_item_schema() { - $weight_unit = get_option( 'woocommerce_weight_unit' ); - $dimension_unit = get_option( 'woocommerce_dimension_unit' ); + $weight_unit_label = I18nUtil::get_weight_unit_label( get_option( 'woocommerce_weight_unit', 'kg' ) ); + $dimension_unit_label = I18nUtil::get_dimensions_unit_label( get_option( 'woocommerce_dimension_unit', 'cm' ) ); $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => $this->post_type, @@ -1935,7 +1937,7 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller { ), 'weight' => array( /* translators: %s: weight unit */ - 'description' => sprintf( __( 'Product weight (%s).', 'woocommerce' ), $weight_unit ), + 'description' => sprintf( __( 'Product weight (%s).', 'woocommerce' ), $weight_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), @@ -1946,19 +1948,19 @@ class WC_REST_Products_V2_Controller extends WC_REST_CRUD_Controller { 'properties' => array( 'length' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Product length (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Product length (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), 'width' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Product width (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Product width (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), 'height' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Product height (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Product height (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), diff --git a/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-product-variations-controller.php b/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-product-variations-controller.php index da5ba612522..e0bab404006 100644 --- a/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-product-variations-controller.php +++ b/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-product-variations-controller.php @@ -8,6 +8,8 @@ * @since 3.0.0 */ +use Automattic\WooCommerce\Utilities\I18nUtil; + defined( 'ABSPATH' ) || exit; use Automattic\Jetpack\Constants; @@ -441,8 +443,8 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Product_Variations_V * @return array */ public function get_item_schema() { - $weight_unit = get_option( 'woocommerce_weight_unit' ); - $dimension_unit = get_option( 'woocommerce_dimension_unit' ); + $weight_unit_label = I18nUtil::get_weight_unit_label( get_option( 'woocommerce_weight_unit', 'kg' ) ); + $dimension_unit_label = I18nUtil::get_dimensions_unit_label( get_option( 'woocommerce_dimension_unit', 'cm' ) ); $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => $this->post_type, @@ -643,7 +645,7 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Product_Variations_V ), 'weight' => array( /* translators: %s: weight unit */ - 'description' => sprintf( __( 'Variation weight (%s).', 'woocommerce' ), $weight_unit ), + 'description' => sprintf( __( 'Variation weight (%s).', 'woocommerce' ), $weight_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), @@ -654,19 +656,19 @@ class WC_REST_Product_Variations_Controller extends WC_REST_Product_Variations_V 'properties' => array( 'length' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Variation length (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Variation length (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), 'width' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Variation width (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Variation width (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), 'height' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Variation height (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Variation height (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), diff --git a/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-products-controller.php b/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-products-controller.php index f7d8ff984be..dbcc4a47bb0 100644 --- a/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-products-controller.php +++ b/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-products-controller.php @@ -8,6 +8,8 @@ * @since 2.6.0 */ +use Automattic\WooCommerce\Utilities\I18nUtil; + defined( 'ABSPATH' ) || exit; /** @@ -804,8 +806,8 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller { * @return array */ public function get_item_schema() { - $weight_unit = get_option( 'woocommerce_weight_unit' ); - $dimension_unit = get_option( 'woocommerce_dimension_unit' ); + $weight_unit_label = I18nUtil::get_weight_unit_label( get_option( 'woocommerce_weight_unit', 'kg' ) ); + $dimension_unit_label = I18nUtil::get_dimensions_unit_label( get_option( 'woocommerce_dimension_unit', 'cm' ) ); $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => $this->post_type, @@ -1080,7 +1082,7 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller { ), 'weight' => array( /* translators: %s: weight unit */ - 'description' => sprintf( __( 'Product weight (%s).', 'woocommerce' ), $weight_unit ), + 'description' => sprintf( __( 'Product weight (%s).', 'woocommerce' ), $weight_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), @@ -1091,19 +1093,19 @@ class WC_REST_Products_Controller extends WC_REST_Products_V2_Controller { 'properties' => array( 'length' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Product length (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Product length (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), 'width' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Product width (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Product width (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), 'height' => array( /* translators: %s: dimension unit */ - 'description' => sprintf( __( 'Product height (%s).', 'woocommerce' ), $dimension_unit ), + 'description' => sprintf( __( 'Product height (%s).', 'woocommerce' ), $dimension_unit_label ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ),