Reputation: 1404
I am using Google Translation Advanced using Golang Client. I see that the input param, SourceLanguageCode
is optional. I have confirmed that if we don't pass the SourceLanguageCode
, the API still returns the result as expected. But when I don't pass the SourceLanguageCode
, does the API call get charged both for Language Detection and Translation?
I looked at the Pricing page and this part is not described clearly: https://cloud.google.com/translate/pricing
I have an option of finding the SourceLanguageCode
from a different library, so I would pass the SourceLanguageCode
as an input param if Google Translate charges me twice the amount for every API call if that is not passed.
But, if Google Translate doesn't charge for Language Detection separately for Translation, I would rather let Google decide the source language automatically.
For reference, this is how I am getting the translatedText
and detectedLanguage
from the Golang client:
Example: https://cloud.google.com/translate/docs/advanced/translating-text-v3#translating_input_strings
My code:
for _, translation := range resp.GetTranslations() {
fmt.Fprintf(w, "Translated text: %v\n", translation.GetTranslatedText())
fmt.Fprintf(w, "Detected language: %v\n", translation.DetectedLanguageCode())
}
Any help is appreciated. Thanks.
Upvotes: 1
Views: 1158
Reputation: 1404
The pricing link answers the question that we will be only charged once even if we don't specify the source language: https://cloud.google.com/translate/pricing
You are only charged for the text that you provided; there's no additional charge for the detection in addition to the translation. For example, if you submit 1,000 characters for translation without specifying the source language, you are only charged for the 1,000 characters.
Upvotes: 3