Skip to content

Commit

Permalink
Switch to override_load_textdomain filter instead of `plugin_locale…
Browse files Browse the repository at this point in the history
…` filter.

Closes #24.
  • Loading branch information
remcotolsma committed Oct 2, 2024
1 parent 21f6e46 commit 60c621b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions classes/QueryMonitorModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,25 @@ public function plugins_loaded() {
return;
}

\add_filter( 'plugin_locale', [ $this, 'plugin_locale' ], 10, 2 );
\add_filter( 'override_load_textdomain', [ $this, 'override_load_textdomain' ], 10, 2 );
}

/**
* For English for Query Monitor plugin.
*
* @link https://github.com/johnbillion/query-monitor/blob/60da795c040e0f08850891c74a36b2f566cee14d/classes/QueryMonitor.php#L162-L167
* @link https://github.com/WordPress/wordpress-develop/blob/2bb5679d666474d024352fa53f07344affef7e69/src/wp-includes/l10n.php#L69-L71
* @param string $locale The plugin's current locale.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return string
* @link https://github.com/WordPress/wordpress-develop/blob/2bb5679d666474d024352fa53f07344affef7e69/src/wp-includes/l10n.php#L711-L726
* @link https://github.com/pronamic/wp-pronamic-client/issues/24
* @param bool $override Whether to override the .mo file loading. Default false.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
*/
public function plugin_locale( $locale, $domain ) {
if ( 'query-monitor' !== $domain ) {
return $locale;
public function override_load_textdomain( $override, $domain ) {
if ( 'query-monitor' === $domain ) {
$override = true;
}

return 'en_US';
return $override;
}


Expand Down

0 comments on commit 60c621b

Please sign in to comment.