Japanese (speaking) developer needed for a bit of regex magic
clp2 at rebertia.com
Wed Apr 21 08:09:29 EDT 2010
On Wed, Apr 21, 2010 at 4:46 AM, Sebastian <basti at redtoad.de> wrote:
>> > My regular expressions turn the Amazon error messages into Python
>> > exceptions.
>> > This works fine as long as they are in English: "??? is not a valid
>> > value for BrowseNodeId. Please change this value and retry your
>> > request.", for instance, will raise an InvalidParameterValue
>> > exception. However, the Japanese version returns the error message
>> > "??? は、BrowseNodeIdの値として無効です。値を変更してから、再度リクエス
>> > トを実行してください。" which will not be successfully handled.
>> > This renders the my module pretty much useless for Japanese users.
>> Your problem, then, appears to be that you're attacking the issue at the
>> wrong layer. Parsing messages in natural language and hoping to
>> reconstruct a structure is going to be an exercise in frustration.
>> Doesn't the API have defined response codes and parameters that you can
>> use, instead of parsing error strings in various natural languages?
> No, unfortunately not. If it did, I would have used it.
> The Amazon API returns an XML response which contains error messages
> if a request fails. These messages consist of an error code and an
> error description in natural language. Luckily, the description seems
> to stick to the same format and is (in all but one case) in plain
> English. Much to my dismay I discovered that the Japanese locale
> translates the error message!
> For example, this is the bit of XML returned for the German locale:
> <Message>??? is not a valid value for BrowseNodeId. Please
> change this value and retry your request.</Message>
> The corresponding part from the Japanese locale looks like this:
> Of course, one could argue that the type of error (in this case
> "AWS.InvalidParameterValue") would be enough. However, in order to
> return a maeningful error message, I would like to parse the
> description itself - and for this some knowledge of Japanese would be
Just throwing this out there, but perhaps you could grep for the
relevant terms in the error message and intuit it from there?
# terms = whatever the actual param names are
terms = "BrowseNodeId FooNodeId FooQueryType".split()
for term in terms:
if term in err_msg:
raise AmazonError, err_code + " for " +repr(term)
More information about the Python-list