guptahanu / google-ajax-apis

Automatically exported from code.google.com/p/google-ajax-apis
0 stars 1 forks source link

Translation API v2 rejects upper-case country codes in target parameter (zh-CN, zh-TW) #549

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The bug described herein was reported by another user in the APIs forum.

   http://groups.google.com/group/google-ajax-search-api/browse_frm/thread/6cdeb1034b86480d

Translation API v2 should support the following language tags, as shown in 
documentation:

   Chinese Simplified:  zh-CN
   Chinese Traditional:  zh-TW

   https://code.google.com/apis/language/translate/v2/using_rest.html#language-params

But currently the v2 API returns a "Bad Language Pair" error message if the 
request specifies "zh-CN" or "zh-TW" (with upper-case country code) as the 
"target" parameter value.

Requested fix:

Translation API v2 should support the use of upper-case country codes in these 
language tags, as documented.  Specifying "zh-CN" or "zh-TW" as the "target" 
parameter value should not cause an error.

Note:

Currently the API accepts a lower-case country code in these language tags: 
"zh-cn", "zh-tw".  (The API also accepts "zh" and "zh-Hant".)

I do not wish to take a position on the question of whether the API should or 
should not continue to accept language tags with lower-case country codes.  In 
any case, the API should support the use of upper-case country codes in these 
tags ("zh-CN", "zh-TW") as documented.

References:

   https://code.google.com/apis/language/translate/v2/using_rest.html#language-params

   http://tools.ietf.org/rfc/bcp/bcp47.txt
   >
   > "... The format of subtags in the registry is RECOMMENDED as the form to use in language tags.  This format generally corresponds to the common conventions for the various ISO standards from which the subtags are derived.  These conventions include:" [...] [...] [ISO 3166-1] "recommends that country codes be" [specified in upper-case] ....

Test examples follow.
(Note:  Change "KEY" to your key.)

Tests with upper-case country codes (in "zh-CN" and "zh-TW"):
These tests produce the unexpected "Bad Language Pair" error message.

   https://www.googleapis.com/language/translate/v2?key=KEY&callback=test&q=language&source=en&target=zh-CN

   https://www.googleapis.com/language/translate/v2?key=KEY&callback=test&q=language&source=en&target=zh-TW

Tests with lower-case country codes (in "zh-cn" and "zh-tw"):
These tests produce translations without error.

   https://www.googleapis.com/language/translate/v2?key=KEY&callback=test&q=language&source=en&target=zh-cn

   https://www.googleapis.com/language/translate/v2?key=KEY&callback=test&q=language&source=en&target=zh-tw

Tests with alternative tag format ("zh" and "zh-Hant"):
These tests produce translations without error.

   https://www.googleapis.com/language/translate/v2?key=KEY&callback=test&q=language&source=en&target=zh

   https://www.googleapis.com/language/translate/v2?key=KEY&callback=test&q=language&source=en&target=zh-Hant

Original issue reported on code.google.com by omr99...@yahoo.com on 4 Dec 2010 at 1:22

GoogleCodeExporter commented 8 years ago

Original comment by jsill...@google.com on 7 Dec 2010 at 1:52

GoogleCodeExporter commented 8 years ago

Original comment by jsill...@google.com on 9 Dec 2010 at 1:23