WooCommerce Code Reference

I18nUtil
in package

A class of utilities for dealing with internationalization.

Table of Contents

$units  : array<string|int, mixed>
A cache for the i18n units data.
get_dimensions_unit_label()  : string
Get the translated label for a dimensions unit of measure.
get_weight_unit_label()  : string
Get the translated label for a weight unit of measure.

Properties

Methods

get_dimensions_unit_label()

Get the translated label for a dimensions unit of measure.

public static get_dimensions_unit_label(string $dimensions_unit) : string

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.

Parameters
$dimensions_unit : string

The abbreviated dimension unit in English, e.g. cm.

Return values
string

get_weight_unit_label()

Get the translated label for a weight unit of measure.

public static get_weight_unit_label(string $weight_unit) : string

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.

Parameters
$weight_unit : string

The abbreviated weight unit in English, e.g. kg.

Return values
string