googleapis / google-cloud-python

Google Cloud Client Library for Python
https://googleapis.github.io/google-cloud-python/
Apache License 2.0
4.8k stars 1.51k forks source link

Translate: get_supported_languages() should return both locale codes for Hebrew and Chinese. #9592

Closed verhovsky closed 4 years ago

verhovsky commented 4 years ago

https://cloud.google.com/translate/docs/languages says that Hebrew is a supported language with two language codes "he or iw". But when you do get_supported_languages, only the latter is returned. Same for "zh" and "zh-CN".

from pathlib import Path

from google.cloud.translate import TranslationServiceClient
from google.oauth2 import service_account

creds = "creds.json"

credentials = service_account.Credentials.from_service_account_file(creds)
project_id = "projects/" + credentials.project_id

google_translate = TranslationServiceClient(credentials=credentials)
result = google_translate.get_supported_languages(parent=project_id)

language_codes = [lang.language_code for lang in result.languages]
print(language_codes)
print("he" in language_codes)
print("iw" in language_codes)
print("zh" in language_codes)

outputs

['af', 'am', 'ar', 'az', 'be', 'bg', 'bn', 'bs', 'ca', 'ceb', 'co', 'cs', 'cy', 'da', 'de', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fa', 'fi', 'fr', 'fy', 'ga', 'gd', 'gl', 'gu', 'ha', 'haw', 'hi', 'hmn', 'hr', 'ht', 'hu', 'hy', 'id', 'ig', 'is', 'it', 'iw', 'ja', 'jw', 'ka', 'kk', 'km', 'kn', 'ko', 'ku', 'ky', 'la', 'lb', 'lo', 'lt', 'lv', 'mg', 'mi', 'mk', 'ml', 'mn', 'mr', 'ms', 'mt', 'my', 'ne', 'nl', 'no', 'ny', 'pa', 'pl', 'ps', 'pt', 'ro', 'ru', 'sd', 'si', 'sk', 'sl', 'sm', 'sn', 'so', 'sq', 'sr', 'st', 'su', 'sv', 'sw', 'ta', 'te', 'tg', 'th', 'tl', 'tr', 'uk', 'ur', 'uz', 'vi', 'xh', 'yi', 'yo', 'zh-CN', 'zh-TW', 'zu']
False
True
False

Or you could just return he instead, since iw was withdrawn in 1989. https://www.loc.gov/standards/iso639-2/php/code_list.php gives the ISO 639-1 code of Hebrew as he.

Regardless of that, you should still also return zh in that list.

nnegrey commented 4 years ago

Howdy these sound like either API backend issues or documentation issues not related to the library itself.

Please file backend API issues here: https://cloud.google.com/support/docs/issue-trackers or docs issues directly on the docs page: https://cloud.google.com/translate/docs/languages via the "Send Feedback" button.

My guess is that you can input either, but we probably only return 1.

verhovsky commented 4 years ago

https://issuetracker.google.com/issues/144111435