Stichoza / google-translate-php

🔤 Free Google Translate API PHP Package. Translates totally free of charge.
MIT License
1.79k stars 380 forks source link

Bug report: preserveParameters gives unexpected results when translating to French #201

Closed charescape closed 7 months ago

charescape commented 7 months ago

What steps will reproduce the problem?

$google = new GoogleTranslate();

$google->setSource('en');
$google->setTarget('fr');

echo $google->preserveParameters('#\{([^}]+)}#')->translate('What is {real_q_encoded}?');

What is the expected result?

Qu'est-ce que {real_q_encoded} ?

What do you get instead?

Qu'est-ce que {0} $ ?

kylemilloy commented 7 months ago

I just ran into this myself...I was the one that introduced the change...If we change the encoding to #{0} it should do it...seems localized to only some situations when doing french. I'll make a PR.