Automattic\WooCommerce\Utilities

I18nUtil::get_weight_unit_label()public staticWC 1.0

Get the translated label for a weight unit of measure.

This will return the original input string if it isn't found in the units array. This way a custom unit of measure can be used even if it's not getting translated.

Method of the class: I18nUtil{}

No Hooks.

Return

String.

Usage

$result = I18nUtil::get_weight_unit_label( $weight_unit );
$weight_unit(string) (required)
The abbreviated weight unit in English, e.g. kg.

I18nUtil::get_weight_unit_label() code WC 8.9.0

public static function get_weight_unit_label( $weight_unit ) {
	if ( empty( self::$units ) ) {
		self::$units = include WC()->plugin_path() . '/i18n/units.php';
	}

	$label = $weight_unit;

	if ( ! empty( self::$units['weight'][ $weight_unit ] ) ) {
		$label = self::$units['weight'][ $weight_unit ];
	}

	return $label;
}