From 141c3f3f600c0f7dad348f6f857779111b9efc8f Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 16 May 2026 22:17:32 +0200 Subject: [PATCH] Add translators comments and number sprintf placeholders --- src/Admin/Module.php | 3 +++ src/Admin/Settings/API.php | 9 ++++++--- src/Admin/Settings/Hooks.php | 2 ++ src/Admin/Settings/Page.php | 10 +++++++++- src/Admin/Upgrades.php | 6 ++++-- src/Ajax.php | 3 ++- src/Client.php | 6 ++++++ src/Integrations/EDD.php | 1 + src/Integrations/WooCommerce.php | 1 + 9 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/Admin/Module.php b/src/Admin/Module.php index b383b8bd..8ee4ed9d 100644 --- a/src/Admin/Module.php +++ b/src/Admin/Module.php @@ -97,6 +97,7 @@ public function install() { private function show_module_not_installed_error() { $message = sprintf( wp_kses( + // translators: %s: URL to manual proxy speed module installation instructions. __( 'The proxy is enabled, but the proxy\'s speed module failed to install. Try installing it manually.', 'plausible-analytics' @@ -211,6 +212,7 @@ public function maybe_enable_proxy( $settings, $old_settings ) { if ( ! $is_ssl ) { Messages::set_notice( sprintf( + // translators: %s: URL to list of potential proxy solutions. __( 'Please check that your proxy is functioning correctly. If you encounter any issues with tracking, click here for a list of potential solutions', 'plausible-analytics' @@ -227,6 +229,7 @@ public function maybe_enable_proxy( $settings, $old_settings ) { Messages::set_error( sprintf( wp_kses( + // translators: 1: Proxy endpoint URL, 2: URL to Plausible support. __( 'Plausible\'s proxy couldn\'t be enabled, because the WordPress API is inaccessible. This might be due to a conflicting setting in a (security) plugin or server firewall. Make sure you whitelist requests to the Proxy\'s endpoint: %1$s. Contact support if you need help locating the issue.', 'plausible-analytics' diff --git a/src/Admin/Settings/API.php b/src/Admin/Settings/API.php index 7563f46d..4fd01689 100644 --- a/src/Admin/Settings/API.php +++ b/src/Admin/Settings/API.php @@ -70,8 +70,9 @@ public function settings_page() { ]; $this->slides_description = [ 'welcome' => sprintf( + // translators: 1: URL to Plausible website, 2: URL to Plausible registration page. __( - '

Plausible Analytics is an easy to use, open source, lightweight and privacy-friendly alternative to Google Analytics. We\'re super excited to have you on board!

To use our plugin, you need to register an account. To explore the product, we offer you a free 30-day trial. No credit card is required to sign up for the trial.

Already have an account? Please do follow the following steps to get the most out of your Plausible experience.

', + '

Plausible Analytics is an easy to use, open source, lightweight and privacy-friendly alternative to Google Analytics. We\'re super excited to have you on board!

To use our plugin, you need to register an account. To explore the product, we offer you a free 30-day trial. No credit card is required to sign up for the trial.

Already have an account? Please do follow the following steps to get the most out of your Plausible experience.

', 'plausible-analytics' ), 'https://plausible.io/?utm_source=WordPress&utm_medium=Referral&utm_campaign=WordPress+plugin', @@ -95,8 +96,9 @@ public function settings_page() { 'plausible-analytics' ), 'success' => sprintf( + // translators: 1: URL to Plausible statistics dashboard, 2: URL to plugin settings, 3: URL to Plausible documentation, 4: URL to Plausible contact. __( - '

Congrats! Your traffic is now being counted without compromising the user experience and privacy of your visitors. You can now check out your intuitive, fast-loading and privacy-friendly dashboard.

Note that visits from logged in users aren\'t tracked. If you want to track visits for certain user roles, then please specify them in the plugin\'s settings.

Need help? Our documentation is the best place to find most answers right away.

Still haven\'t found the answer you\'re looking for? We\'re here to help. Please contact our support.

', + '

Congrats! Your traffic is now being counted without compromising the user experience and privacy of your visitors. You can now check out your intuitive, fast-loading and privacy-friendly dashboard.

Note that visits from logged in users aren\'t tracked. If you want to track visits for certain user roles, then please specify them in the plugin\'s settings.

Need help? Our documentation is the best place to find most answers right away.

Still haven\'t found the answer you\'re looking for? We\'re here to help. Please contact our support.

', 'plausible-analytics' ), admin_url( 'index.php?page=plausible_analytics_statistics' ), @@ -108,8 +110,9 @@ public function settings_page() { if ( empty( $settings['enable_analytics_dashboard'] ) ) { $this->slides_description['success'] = sprintf( + // translators: 1: URL to plugin settings, 2: URL to Plausible documentation, 3: URL to Plausible contact. __( - '

Congrats! Your traffic is now being counted without compromising the user experience and privacy of your visitors.

Note that visits from logged in users aren\'t tracked. If you want to track visits for certain user roles, then please specify them in the plugin\'s settings.

Need help? Our documentation is the best place to find most answers right away.

Still haven\'t found the answer you\'re looking for? We\'re here to help. Please contact our support.

', + '

Congrats! Your traffic is now being counted without compromising the user experience and privacy of your visitors.

Note that visits from logged in users aren\'t tracked. If you want to track visits for certain user roles, then please specify them in the plugin\'s settings.

Need help? Our documentation is the best place to find most answers right away.

Still haven\'t found the answer you\'re looking for? We\'re here to help. Please contact our support.

', 'plausible-analytics' ), admin_url( 'admin-ajax.php?action=plausible_analytics_quit_wizard&_nonce=' ) . wp_create_nonce( 'plausible_analytics_quit_wizard' ) . '&redirect=tracked_user_roles', diff --git a/src/Admin/Settings/Hooks.php b/src/Admin/Settings/Hooks.php index 4570a5f2..90931d86 100644 --- a/src/Admin/Settings/Hooks.php +++ b/src/Admin/Settings/Hooks.php @@ -74,6 +74,7 @@ public function proxy_warning() { } else { echo sprintf( wp_kses( + // translators: %s: URL to Plausible contact page. __( 'After enabling this option, please check your Plausible dashboard to make sure stats are being recorded. Are stats not being recorded? Do reach out to us. We\'re here to help!', 'plausible-analytics' @@ -110,6 +111,7 @@ public function enable_analytics_dashboard_notice() { if ( ! empty( Helpers::get_settings()[ 'enable_analytics_dashboard' ] ) ) { echo sprintf( wp_kses( + // translators: %s: URL to the analytics dashboard. __( 'Your analytics dashboard is available here.', 'plausible-analytics' diff --git a/src/Admin/Settings/Page.php b/src/Admin/Settings/Page.php index b016c0ab..0b2c9a26 100644 --- a/src/Admin/Settings/Page.php +++ b/src/Admin/Settings/Page.php @@ -93,6 +93,7 @@ public function __construct() { 'type' => 'group', 'desc' => sprintf( wp_kses( + // translators: %s: URL to Plausible account settings. __( 'Ensure your domain name matches the one in your Plausible account, then create a Plugin Token (link opens in a new window) and paste it into the \'Plugin Token\' field.', 'plausible-analytics' @@ -181,6 +182,7 @@ public function __construct() { 'affiliate-links-patterns' => [ 'slug' => 'affiliate_links', 'description' => sprintf( + // translators: %s: Example URL to affiliate product. __( 'Enter the (partial) URLs you\'d like to track. E.g. enter /recommends/ if you want to track %s.', 'plausible-analytics' @@ -232,6 +234,7 @@ public function __construct() { 'query-params-patterns' => [ 'slug' => 'query_params', 'description' => sprintf( + // translators: %s: Example URL with query parameter. __( 'Enter the query parameters you\'d like to track. E.g. enter lang if you want to track %s.', 'plausible-analytics' @@ -266,6 +269,7 @@ public function __construct() { 'type' => 'group', 'desc' => sprintf( wp_kses( + // translators: 1: Proxy endpoint prefix, 2: Proxy endpoint details, 3: URL to learn more about proxy. __( 'Concerned about ad blockers? You can run the Plausible script as a first-party connection from your domain name to count visitors who use ad blockers. The proxy uses WordPress\' API with a randomly generated endpoint, starting with %1$s and %2$s. Learn more »', 'plausible-analytics' @@ -423,6 +427,7 @@ public function __construct() { 'slug' => 'self_hosted_shared_link', 'type' => 'group', 'desc' => sprintf( + // translators: %s: URL to Plausible shared link documentation. '
  1. ' . __( 'Create a secure and private shared link in your Plausible account.', 'plausible-analytics' @@ -439,7 +444,8 @@ public function __construct() { 'type' => 'text', 'value' => $settings['self_hosted_shared_link'], 'placeholder' => sprintf( - wp_kses( __( 'E.g. %s/share/%s?auth=XXXXXXXXXXXX', 'plausible-analytics' ), 'post' ), + // translators: 1: Plausible hosted domain URL, 2: Site domain name. + wp_kses( __( 'E.g. %1$s/share/%2$s?auth=XXXXXXXXXXXX', 'plausible-analytics' ), 'post' ), Helpers::get_hosted_domain_url(), Helpers::get_domain() ), @@ -734,6 +740,7 @@ public function render_analytics_dashboard() {

    Shared Link under Self-Hosted Settings.', 'plausible-analytics' @@ -742,6 +749,7 @@ public function render_analytics_dashboard() { ); ?> click here to enable View Stats in WordPress.', 'plausible-analytics' diff --git a/src/Admin/Upgrades.php b/src/Admin/Upgrades.php index 07532d86..7c1bef8c 100644 --- a/src/Admin/Upgrades.php +++ b/src/Admin/Upgrades.php @@ -409,7 +409,8 @@ public function show_ce_api_token_notice() { ?>

    -

    Settings screen and upgrade Plausible CE if necessary.', 'plausible-analytics' ), $url ); ?>

    +

    Settings screen and upgrade Plausible CE if necessary.', 'plausible-analytics' ), $url ); ?>

    -

    Settings screen, and press Connect to complete setup.', 'plausible-analytics' ), $url ); ?>

    +

    Settings screen, and press Connect to complete setup.', 'plausible-analytics' ), $url ); ?>

    create a new token. Read more', + 'Oops! The Plugin Token you used is invalid. Please create a new token. Read more', 'plausible-analytics' ), "$hosted_domain/$domain/settings/integrations?new_token=WordPress", diff --git a/src/Client.php b/src/Client.php index 5b64cae0..f639d076 100644 --- a/src/Client.php +++ b/src/Client.php @@ -232,6 +232,7 @@ public function update_tracker_script_configuration( $tracker_script_config_upda } catch ( Exception $e ) { $this->send_json_error( $e, + // translators: %s: Error message. __( 'Something went wrong while updating tracker script configuration: %s', 'plausible-analytics' @@ -303,6 +304,7 @@ public function create_shared_link() { $result = $this->bulk_create_shared_links(); // @codeCoverageIgnoreStart } catch ( Exception $e ) { + // translators: %s: Error message. $this->send_json_error( $e, __( 'Something went wrong while creating Shared Link: %s', 'plausible-analytics' ) ); // @codeCoverageIgnoreEnd } @@ -341,6 +343,7 @@ public function create_goals( $goals ) { try { return $this->api_instance->goalGetOrCreate( $goals ); } catch ( Exception $e ) { + // translators: %s: Error message. $this->send_json_error( $e, __( 'Something went wrong while creating Custom Event Goal: %s', 'plausible-analytics' ) ); } } @@ -358,6 +361,7 @@ public function create_funnel( $funnel ) { try { return $this->api_instance->funnelGetOrCreate( $funnel ); } catch ( Exception $e ) { + // translators: %s: Error message. $this->send_json_error( $e, __( 'Something went wrong while creating Funnel: %s', 'plausible-analytics' ) ); } } @@ -375,6 +379,7 @@ public function delete_goal( $id ) { } catch ( Exception $e ) { $this->send_json_error( $e, + // translators: %s: Error message. __( 'Something went wrong while deleting a Custom Event Goal: %s', 'plausible-analytics' @@ -398,6 +403,7 @@ public function enable_custom_property( $enable_request ) { } catch ( Exception $e ) { $this->send_json_error( $e, + // translators: %s: Error message. __( 'Something went wrong while enabling Pageview Properties: %s', 'plausible-analytics' diff --git a/src/Integrations/EDD.php b/src/Integrations/EDD.php index 842d99ab..58fa1497 100644 --- a/src/Integrations/EDD.php +++ b/src/Integrations/EDD.php @@ -34,6 +34,7 @@ public function __construct( $init = true ) { } $this->event_goals = [ + // translators: %s: Product page URI pattern. 'view-product' => sprintf( __( 'Visit %s*', 'plausible-analytics' ), $uri ), 'add-to-cart' => __( 'EDD Add to Cart', 'plausible-analytics' ), 'remove-from-cart' => __( 'EDD Remove from Cart', 'plausible-analytics' ), diff --git a/src/Integrations/WooCommerce.php b/src/Integrations/WooCommerce.php index e20c408c..474b257e 100644 --- a/src/Integrations/WooCommerce.php +++ b/src/Integrations/WooCommerce.php @@ -37,6 +37,7 @@ public function __construct( $init = true ) { } $this->event_goals = [ + // translators: %s: Product page URI pattern. 'view-product' => sprintf( __( 'Visit %s*', 'plausible-analytics' ), $uri ), 'add-to-cart' => __( 'Woo Add to Cart', 'plausible-analytics' ), 'remove-from-cart' => __( 'Woo Remove from Cart', 'plausible-analytics' ),