
Google Business Profiles API: Reviews Without Translation
When working with APIs documentation is sometimes unclear or not covering all use cases. Google Business Profiles API offers reference covering most of the uses cases well. However for reviews, they don’t talk about API responses returned with (Original) and (Translated by Google) texts. It’s likely that the documentation was written by English speakers in the US, who didn’t even have experience with these (Translated by Google) review texts along the (Original).
To complicate things further, different translation languages are provided for different accounts, likely based on the account language preference.
The documentation for reviews (v4.9) list and get actions does not mention these translations in any way. So I decided to investigate if there was a way to not receive these translated reviews and only request an original review text.
How to receive original review only without translation using GBP API?
There is an undocumented feature of the GBP API for reviews. After searching a lot I found this single Stack Overflow question without an accepted answer. However, the answer provided gave me enough hints to test and validate it.
Solution: use Accept-Language in your API request
The solution is to provide Accept-Language header in your request. If most of your reviews are in in language different than English, just provide that language code using this header.
E.g. if most of the reviews for the account I was working with were in Slovak and some in Czech, I would provide these values in order of priority:
Accept-Language: sk;q=0.9,cs;q=0.8,en;q=0.7
This allows me to fetch Slovak and Czech reviews without translation and have all others in any other language along with a translation to English.
You can include multiple languages, if you are OK with receiving their texts in the original language instead of receiving both the original and the translation.
Only caveat can be that once you start using Accept-Language header, (Original) and (Translated by Google) will also get translated to the primary language provided, in my case this was Slovak: (Preložené Googlom) for translation and (Pôvodné) for original.
Different solution: stripping the translated review
Another solution to fix this issue is to strip the translated text from the response. You can do it easily in these three steps:
- Locate the “(Translated by Google)” string
- Strip that line and any lines down (or up, see below) to the “(Original)” string
- Done
Caveats
Beware, that the order of the original and the translation changes, so sometimes the original comes first, other time the translation will be first in the Google Business Profiles API response. Sometimes the (Original) string is not even provided (!).