Skip to content

Commit

Permalink
Donn't exit process on missing placeholder
Browse files Browse the repository at this point in the history
That's a bit too rigorous for something that can be fixed manually.
Now it logs an error instead.
  • Loading branch information
q-- committed Jul 2, 2024
1 parent b7e0bc9 commit c154a11
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Drivers/Translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit c154a11

Please sign in to comment.