Skip to content

Commit

Permalink
Remove space in the parameters
Browse files Browse the repository at this point in the history
Google adds in some language some space inside the parameters (ex. #{ 21}), this will remove it before parsing it.
  • Loading branch information
Chitzi committed Jun 26, 2024
1 parent bd9ef8a commit f47197b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/GoogleTranslate.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ function ($matches) {
*/
protected function injectParameters(string $string, array $replacements): string
{
// Remove space added by google in the parameters
$string = preg_replace('/#\{\s*(\d+)\s*\}/', '#{$1}', $string);

return preg_replace_callback(
'/\#{(\d+)}/',
fn($matches) => $replacements[$matches[1]],
Expand Down

0 comments on commit f47197b

Please sign in to comment.