From 21bae97e82469e2c25a5c93e1b4c955453fc6cff Mon Sep 17 00:00:00 2001 From: Corey McKrill <916023+coreymckrill@users.noreply.github.com> Date: Tue, 31 Jan 2023 17:12:11 -0800 Subject: [PATCH] Add I18nUtil class --- .../woocommerce/src/Utilities/I18nUtil.php | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 plugins/woocommerce/src/Utilities/I18nUtil.php diff --git a/plugins/woocommerce/src/Utilities/I18nUtil.php b/plugins/woocommerce/src/Utilities/I18nUtil.php new file mode 100644 index 00000000000..428790d76b2 --- /dev/null +++ b/plugins/woocommerce/src/Utilities/I18nUtil.php @@ -0,0 +1,55 @@ +plugin_path() . '/i18n/units.php'; + } + + $label = ''; + + 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. + * + * @param string $dimensions_unit + * + * @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 = ''; + + if ( ! empty( self::$units['dimensions'][ $dimensions_unit ] ) ) { + $label = self::$units['dimensions'][ $dimensions_unit ]; + } + + return $label; + } +}