Automattic\WooCommerce\Utilities
I18nUtil::get_weight_unit_label
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.
Returns
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() I18nUtil::get weight unit label code WC 10.3.6
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;
}