language[-Script] format: a language code, optionally followed by an ISO 15924 script code, with no region. For example en, ar, ja, hi-Latn (Hindi in Latin script), zh-Hans (Simplified Chinese) and zh-Hant (Traditional Chinese).
- The language is the shortest ISO 639 code: the two-letter ISO 639-1 code when one exists (
en,ar), otherwise the three-letter code (ace,ckb). - The script is omitted when it is the language’s default (
en,ja,ko) and written when it differs from the default (hi-Latn). - Languages written in several scripts always include the script, for example
zh-Hans,zh-Hant,sr-Cyrl,mni-Mteiandmni-Beng.
This format applies to translation only. Speech-to-Text and Text-to-Speech keep using locales such as
en-US.Accepted input
Language fields in requests also accept other common spellings: ISO 639-3 (eng), <ISO 639-3>_<Script> (eng_Latn, zho_Hans) and BCP 47 tags with a region (zh-TW, pt-BR). Matching ignores letter case, and - and _ are interchangeable. A region only selects the script and is then dropped, so zh-TW becomes zh-Hant and pt-BR becomes pt.
To detect the source language automatically, omit source_language or set it to an empty string or auto.
A language the selected model does not support is rejected. Get Model Details returns each model’s supported languages: translate_capability.target_languages for text translation models and languages for real-time translation models.
Responses
Languages determined by the service, such as detected languages and model language lists, use the
language[-Script] format. A detected language outside the supported list may be returned in the <ISO 639-3>_<Script> format, for example uzn_Latn.
In real-time translation, the ready message and translation.target_language echo the languages you sent in init, while transcript.language and translation.source_language contain the detected language as a code. To compare the two, send your languages in the language[-Script] format.
