Bug: Google Translation API missing zh-CN
Google Translation API “Discovering Supported Languages” contains “zh” but missing “zh-CN”.
But “Detecting Languages” mostly return “zh-CN”, if we search it in this list above, find nothing, it will crash.
Docs say:
Simplified Chinese may be specified either by zh-CN or zh.
Steps to reproduce
curl -H "Authorization: Bearer "$(gcloud auth print-access-token) \
"https://translation.googleapis.com/language/translate/v2/languages"
curl -X POST \
-H "Authorization: Bearer "$(gcloud auth print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
--data "{
'q': '你好世界',
}" "https://translation.googleapis.com/language/translate/v2/detect"
Solution
We need hack this bug until Google fix it.
PHP: