Early translation mitigation (#52199)

* Improve handling (WP 6.7+) when translations are inadvertently loaded early.

* Changelog.
This commit is contained in:
Barry Hughes 2024-10-25 08:26:09 -07:00 committed by GitHub
parent 9be882173c
commit 12f18dc4f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Support situations in which (WooCommerce) translations are inadvertently loaded too early.

View File

@ -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' );
}