3

I have used Google Translate APIs for translating from English to Serbian (with Latin characters).

Since few days ago, using en as source language and sr-Latn I was able to get correct translation but now it does not seem anymore.

Code snippet:

from google.cloud import translate

project_id = "<my project>"
parent = f"projects/{project_id}"
client = translate.TranslationServiceClient()

sample_text = "Hello!"
source_language_code = "en"
target_language_code = "sr-Latn"

response = client.translate_text(
    contents=[sample_text],
    source_language_code=source_language_code,
    target_language_code=target_language_code,
    parent=parent,
)

for translation in response.translations:
    print(translation.translated_text)

Actual output:

Здраво!

Expected output:

Zdravo!

Additional info: sr-Latn is a valid BCP-47 language code and worked since few days ago.

Thanks for you help

2 Answers2

1

They have removed the feature. You can do post translate transliteration from CYR to LAT.

A sample

https://github.com/kukicmilorad/cyrlat

giu fus
  • 26
  • 2
0

It appears that translation to the Serbian Latin Alphabet is not officially supported by the Cloud Translate API, as discussed in this recent issue. Therefore it’s not assured that any possible workaround will be functional or reliable. You can see the list of supported language codes for translation here.

You/We can, however, submit a Feature Request to the public Google issue tracker for Cloud Translation API. The higher the number of us users who bring attention to this request, the more likely it is for it to be eventually built into the API.

Branja
  • 1
  • 1