GNOME Bugzilla – Bug 605641
Does not work with google translate
Last modified: 2014-08-31 13:41:30 UTC
Gives "no definition found" every time trying to use with google translate.
Indeed, it doesn't work anymore. Google now has an API for translation. The plugin should be rewritten to use it. For example: http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&langpair=en|ar&q=hello
Should the fix be available in beta 8?
Yes but I don't know when it's going to be available. I will update this report when the fix is available in the development repository.
Thanks, does it have the full features of the web browser? I mean, like when you go through the web and put one word in to translate it lists many nouns and verbs for the word. It also has a "related phrases" listing which shows you the usage for it. thanks!
You're probably referring to http://www.google.com/dictionary, which is also used by Google translate. Apparently, there's no official API: http://code.google.com/p/google-ajax-apis/issues/detail?id=16. There exists an API but it doesn't seem permitted to use it: http://googlesystem.blogspot.com/2009/12/on-googles-unofficial-dictionary-api.html So when it's updated, the google translate plugin for fantasdic will probably support translation only.
Do you know if there's a way to use google talk for dictionary bots also, then? I know about the translation bots, but is there a way to get dictionary bots or use the dictionary from some other interface other than firefox?
Sorry, I meant to ask, will fantasdic have the translator support for single words like on the website, where it shows you the several nouns and verbs for that word?
Created attachment 152835 [details] [review] patch for google translate you should install json module of ruby manually to use this patch
Thanks for the patch. Apparently, the Google API that you used has additional information, including the dictionary information that the bug reporter was requesting. It would be nice to use it. For example: http://translate.google.com/translate_a/t?client=t&sl=en&tl=fr&text=hello&ie=utf8 By the way, I can't believe that Ruby doesn't include a JSON module in the standard library yet!
Yes, in ruby1.9 there is a build-in json module but you still have to install it manually when using 1.8 :) (In reply to comment #9) > Thanks for the patch. > > Apparently, the Google API that you used has additional information, including > the dictionary information that the bug reporter was requesting. It would be > nice to use it. > > For example: > > http://translate.google.com/translate_a/t?client=t&sl=en&tl=fr&text=hello&ie=utf8 > > By the way, I can't believe that Ruby doesn't include a JSON module in the > standard library yet!
I'm not sure how to use the dict information in google's result, should I just put them into the body of Definition? This could be added in next release. (In reply to comment #9) > Thanks for the patch. > > Apparently, the Google API that you used has additional information, including > the dictionary information that the bug reporter was requesting. It would be > nice to use it. > > For example: > > http://translate.google.com/translate_a/t?client=t&sl=en&tl=fr&text=hello&ie=utf8 > > By the way, I can't believe that Ruby doesn't include a JSON module in the > standard library yet!
Yes the results need be formated in the definition in some way... For 1.8, I'm thinking of rolling the json parser with Fantasdic. I'll try to make a release in a week or two.
Created attachment 176058 [details] [review] Fixed google translate's bug I corrected the problem in another way. Follow the patch.
@Alexandre Parsing the HTML is not safe. Actually Fantasdic broke several times because Google changed their page layout. So I prefer to use the official API, as in the previous patch. However, I want Fantasdic to work with Ruby 1.8 so we need to ship a small json parser with Fantasdic (unless there's a default JSON module in Ruby 1.8??) If one of you want to work on this, please fork Fantasdic's git repository and I will pull from you. Thanks!
@Mathieu There is a way out. I got the idea from Cathal Mc Ginley of Alexandria team. You can do a conversion from json to yaml, which has a build-in module in ruby 1.8 to parse. # This is a quick-and-dirty method to pre-process the JSON into # YAML-parseable format, so that we don't have to drag in a new # dependency. def json2yaml(json) # insert spaces after : and , except within strings # i.e. when followed by numeral, quote, { or [ yaml = json.gsub(/(\:|\,)([0-9'"{\[])/) do |match| "#{$1} #{$2}" end yaml.gsub!(/\\\//, '/') # unescape forward slashes yaml end So with this function, json module is no longer needed.
@Sun Ning That seems like a good idea to me, especially since JSON is a subset of YAML if I remember correctly. If you send me a patch or fork the git repo, I will make sure to include the changes back in the official git repo. If you want, you can also apply for an account @gnome.org http://live.gnome.org/NewAccounts
Seems google has change their api again: http://translate.google.com/translate_a/t?client=t&sl=en&tl=zh&text=hello&ie=utf8 [[["你好","hello","Nǐ hǎo",""]],[["interjection",["喂"]]],"en",,[["你好",[5],,,997,0,1,0]],[["hello",4,,,""],["hello",5,[["你好",997,,],["喂",2,,]],[[0,5]],"hello"]],,,,19] Because of the empty element in the json array, both ruby module of yaml and json cannot handle this. They will threw something like: /usr/lib/ruby/1.8/json/common.rb:122:in `parse': 349: unexpected token at ',[["Hello",[5],1,,919,0,1,0]],[["你好",4,,,""],["你好",5,[["Hello",919,1,],["Hi",49,1,]],[[0,2]],"你好"]],,,,1]' (JSON::ParserError) So painful to handle these dirty strings.
Fantasdic has not seen any code changes since April 2010: https://git.gnome.org/browse/archive/fantasdic This project is not under active development anymore and got archived in GNOME Git. It is currently unlikely that there will be any further active development. Closing this report as WONTFIX as part of Bugzilla Housekeeping to reflect reality. Please feel free to reopen this bug report in the future if anyone takes the responsibility for active development again. If you are interested in maintainership, inform https://mail.gnome.org/mailman/listinfo/desktop-devel-list