Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Utilitie...
File: I18nUtil.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* A class of utilities for dealing with internationalization.
[2] Fix | Delete
*/
[3] Fix | Delete
[4] Fix | Delete
namespace Automattic\WooCommerce\Utilities;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* A class of utilities for dealing with internationalization.
[8] Fix | Delete
*/
[9] Fix | Delete
final class I18nUtil {
[10] Fix | Delete
/**
[11] Fix | Delete
* A cache for the i18n units data.
[12] Fix | Delete
*
[13] Fix | Delete
* @var array $units
[14] Fix | Delete
*/
[15] Fix | Delete
private static $units;
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Get the translated label for a weight unit of measure.
[19] Fix | Delete
*
[20] Fix | Delete
* This will return the original input string if it isn't found in the units array. This way a custom unit of
[21] Fix | Delete
* measure can be used even if it's not getting translated.
[22] Fix | Delete
*
[23] Fix | Delete
* @param string $weight_unit The abbreviated weight unit in English, e.g. kg.
[24] Fix | Delete
*
[25] Fix | Delete
* @return string
[26] Fix | Delete
*/
[27] Fix | Delete
public static function get_weight_unit_label( $weight_unit ) {
[28] Fix | Delete
if ( empty( self::$units ) ) {
[29] Fix | Delete
self::$units = include WC()->plugin_path() . '/i18n/units.php';
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
$label = $weight_unit;
[33] Fix | Delete
[34] Fix | Delete
if ( ! empty( self::$units['weight'][ $weight_unit ] ) ) {
[35] Fix | Delete
$label = self::$units['weight'][ $weight_unit ];
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
return $label;
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Get the translated label for a dimensions unit of measure.
[43] Fix | Delete
*
[44] Fix | Delete
* This will return the original input string if it isn't found in the units array. This way a custom unit of
[45] Fix | Delete
* measure can be used even if it's not getting translated.
[46] Fix | Delete
*
[47] Fix | Delete
* @param string $dimensions_unit The abbreviated dimension unit in English, e.g. cm.
[48] Fix | Delete
*
[49] Fix | Delete
* @return string
[50] Fix | Delete
*/
[51] Fix | Delete
public static function get_dimensions_unit_label( $dimensions_unit ) {
[52] Fix | Delete
if ( empty( self::$units ) ) {
[53] Fix | Delete
self::$units = include WC()->plugin_path() . '/i18n/units.php';
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
$label = $dimensions_unit;
[57] Fix | Delete
[58] Fix | Delete
if ( ! empty( self::$units['dimensions'][ $dimensions_unit ] ) ) {
[59] Fix | Delete
$label = self::$units['dimensions'][ $dimensions_unit ];
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
return $label;
[63] Fix | Delete
}
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function