From 12f18dc4f5c7a19aad2e24e3567566f1b05857e8 Mon Sep 17 00:00:00 2001 From: Barry Hughes <3594411+barryhughes@users.noreply.github.com> Date: Fri, 25 Oct 2024 08:26:09 -0700 Subject: [PATCH] Early translation mitigation (#52199) * Improve handling (WP 6.7+) when translations are inadvertently loaded early. * Changelog. --- .../woocommerce/changelog/fix-early-translation-mitigation | 4 ++++ plugins/woocommerce/includes/class-woocommerce.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 plugins/woocommerce/changelog/fix-early-translation-mitigation diff --git a/plugins/woocommerce/changelog/fix-early-translation-mitigation b/plugins/woocommerce/changelog/fix-early-translation-mitigation new file mode 100644 index 00000000000..983e1028ede --- /dev/null +++ b/plugins/woocommerce/changelog/fix-early-translation-mitigation @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Support situations in which (WooCommerce) translations are inadvertently loaded too early. diff --git a/plugins/woocommerce/includes/class-woocommerce.php b/plugins/woocommerce/includes/class-woocommerce.php index 46276018345..56acd36331c 100644 --- a/plugins/woocommerce/includes/class-woocommerce.php +++ b/plugins/woocommerce/includes/class-woocommerce.php @@ -871,7 +871,7 @@ final class WooCommerce { */ $locale = apply_filters( 'plugin_locale', $locale, 'woocommerce' ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingSinceComment - unload_textdomain( 'woocommerce' ); + unload_textdomain( 'woocommerce', true ); load_textdomain( 'woocommerce', WP_LANG_DIR . '/woocommerce/woocommerce-' . $locale . '.mo' ); load_plugin_textdomain( 'woocommerce', false, plugin_basename( dirname( WC_PLUGIN_FILE ) ) . '/i18n/languages' ); }