Stichoza / google-translate-php

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

Transliteration with preserve parameters #212

Closed Shun-Ibiki closed 2 weeks ago

Shun-Ibiki commented 3 weeks ago

Could the preserve Parameters() be used to get transliteration of the text?

Stichoza commented 3 weeks ago

I didn't understand what you mean. Can you explain?

Shun-Ibiki commented 3 weeks ago

Currently I am using $responseArray = $tr->getResponse('こんにちは') to get romaji/tranliteration of Japanese text. Bur when dealing with html tag, the transliteration of the tag will be messed up. So can I use preserveParameters() to do this job cleanly?

Stichoza commented 3 weeks ago

No it only works with parameters for injecting strings. Params like :this or {{this}} or any regex that doesn't get messed up by Google Translate. HTML tags are not supported. There is a pinned issue (#23) about that topic