From c154a11624a2ae9fd36979c0c132253a739df494 Mon Sep 17 00:00:00 2001 From: q-- <2470175+q--@users.noreply.github.com> Date: Tue, 2 Jul 2024 16:57:06 +0200 Subject: [PATCH] Donn't exit process on missing placeholder That's a bit too rigorous for something that can be fixed manually. Now it logs an error instead. --- src/Drivers/Translation.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Drivers/Translation.php b/src/Drivers/Translation.php index 6b5b731..f576219 100644 --- a/src/Drivers/Translation.php +++ b/src/Drivers/Translation.php @@ -104,9 +104,9 @@ public function getGoogleTranslate($language, $token) // Step 5: Check if the number of placeholders has stayed the same preg_match_all($placeholderRegex, $translatedText, $translatedMatches); if (count($translatedMatches[0]) !== count($placeholders)) { - // Display an error or warning with more details - throw new \ErrorException(sprintf( - "Placeholder count mismatch in translated text.\nOriginal text: %s\nTranslated text: %s\nExpected placeholders: %s\nActual placeholders: %s", + // Print a warning to stderr + fwrite(STDERR, sprintf( + "Warning: Placeholder count mismatch in translated text.\nOriginal text: %s\nTranslated text: %s\nExpected placeholders: %s\nActual placeholders: %s\n", $token, $translatedText, json_encode($placeholders),