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.

Метод класса: I18nUtil{}

Хуков нет.

Возвращает

Строку.

Использование

$result = I18nUtil::get_weight_unit_label( $weight_unit );
$weight_unit(строка) (обязательный)
The abbreviated weight unit in English, e.g. kg.

Код I18nUtil::get_weight_unit_label() WC 8.7.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;
}