Monday, November 15, 2010

Whole-page translation problem in the early versions of Google Dictionary and Google Translate


(The issue is fixed in version 1.2.1.)

Although I had tested all the supported languages with the whole-page translation feature of the Google Dictionary and Google Translate extension for Firefox, the reviewers said that the whole-page translation did not work at all. This puzzled me for quite some time and I rewrote most of that part of code.

The last error they got was an exception of "this.c[0] is undefined" from "https://translate.googleapis.com/translate_static/js/element/main.js Line: 96". That was generated inside the code of Google Translate. I really appreciate they sent me this information as it gave me a hint that Google Translate was expected something from the request. What could it be? I had no clue.

That day, when I was checking the add-on's statistics, I suddenly found that some browsers have their locale set as "Null". What??

Google Dictionary and Google Translate extension has the feature to try to auto detect the language for the user if he/she does not set it, but this feature was not so strong. By setting the locale (general.useragent.locale in configuration) of the browser as "Null" -- a string, I can produce the same error the reviewers did. Why would some browsers have such a strange locale? It is still a mystery to me. I soon found out that not only "Null", but also many of the locales which have flavors could cause the problem.

It is always easier to fix than to find the bug. After I have strengthened the language auto-detection feature in version 1.2.1, the problem is gone. It seems the language auto-detection works only on Windows platform, but at least now anything of the locale does not bother the add-on any more.


No comments:

 
Get This <