PHP 8.2.31
Preview: I18nUtil.php Size: 1.69 KB
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/woocommerce/src/Utilities/I18nUtil.php

<?php
/**
 * A class of utilities for dealing with internationalization.
 */

namespace Automattic\WooCommerce\Utilities;

/**
 * A class of utilities for dealing with internationalization.
 */
final class I18nUtil {
	/**
	 * A cache for the i18n units data.
	 *
	 * @var array $units
	 */
	private static $units;

	/**
	 * 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.
	 *
	 * @param string $weight_unit The abbreviated weight unit in English, e.g. kg.
	 *
	 * @return string
	 */
	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;
	}

	/**
	 * Get the translated label for a dimensions 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.
	 *
	 * @param string $dimensions_unit The abbreviated dimension unit in English, e.g. cm.
	 *
	 * @return string
	 */
	public static function get_dimensions_unit_label( $dimensions_unit ) {
		if ( empty( self::$units ) ) {
			self::$units = include WC()->plugin_path() . '/i18n/units.php';
		}

		$label = $dimensions_unit;

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

		return $label;
	}
}

Directory Contents

Dirs: 0 × Files: 14

Name Size Perms Modified Actions
12.99 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
4.40 KB lrw-r--r-- 2026-01-19 14:46:18
Edit Download
1.10 KB lrw-r--r-- 2024-05-30 18:23:46
Edit Download
5.19 KB lrw-r--r-- 2026-01-26 10:40:36
Edit Download
1.69 KB lrw-r--r-- 2023-02-22 07:17:34
Edit Download
3.18 KB lrw-r--r-- 2024-08-27 23:04:44
Edit Download
1.87 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
7.11 KB lrw-r--r-- 2025-07-29 12:34:58
Edit Download
9.19 KB lrw-r--r-- 2025-11-24 23:10:10
Edit Download
12.99 KB lrw-r--r-- 2025-10-06 17:56:06
Edit Download
5.01 KB lrw-r--r-- 2025-11-24 23:10:10
Edit Download
1020 B lrw-r--r-- 2025-05-12 21:07:28
Edit Download
5.09 KB lrw-r--r-- 2024-06-04 15:20:30
Edit Download
1.16 KB lrw-r--r-- 2024-01-30 23:24:56
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).