gtranslate icon indicating copy to clipboard operation
gtranslate copied to clipboard

Port to new WebExtension format

Open PerfectSlayer opened this issue 8 years ago • 60 comments

Hi all,

Mozilla introduce a new way to develop add-on (again). Here comes the WebExtensions. The main advantages of WebExtension for gTranslate are the following:

  • Support several browsers
  • Faster review

But we need to repackage and use the new common API.

There is already some issues that could be fixed with:

  • #65 Firefox Android support
  • #13 Google Chrome compatibility
  • #53 Pale Moon Browser support

And some that could be easier with:

  • #46 Replace the selection by the translation (as WebExtesions know how to deal with Electrolysis)

Moreover, this new extension format seems to be largely adopted by browser in the coming month. It could be a good way to gTranstale to become even more popular throw the other browser.

So what do you think about porting the current add-on ?

PerfectSlayer avatar Apr 30 '16 07:04 PerfectSlayer

It's really nice to finally see progress towards a standard way of building addons!

I'm all for it, let's see if the API is complete enough to reproduce the current state of the addon.

I don't see any mention of a contextual menu API here, not sure if it's supported yet? https://blog.mozilla.org/addons/2016/04/29/webextensions-in-firefox-48/

bpierre avatar Apr 30 '16 14:04 bpierre

As far I could see, all the API are here:

Those API work for Firfox (since version 45), Chrome and Opera (since version 33). Do you see anything missing to get the add-on working?

I checked the development tutorials. It seems we just need to repack and use the right API but it should not be so hard. Otherwise, we'll need to find testers for other browsers! 😅

PerfectSlayer avatar Apr 30 '16 19:04 PerfectSlayer

I checked the contextMenus API, and it looks like there is no support for nested menus at the moment.

bpierre avatar May 16 '16 08:05 bpierre

I think you just have to add a parentId in the createProperties object.

PerfectSlayer avatar May 17 '16 19:05 PerfectSlayer

Ah, I didn’t see that, cool!

bpierre avatar May 18 '16 12:05 bpierre

Yep, everything should be here to start a port :wink:

PerfectSlayer avatar May 18 '16 18:05 PerfectSlayer

Please increase (with an option) the font size of tooltip translation. The rest seems perfect. :-) UPDATE: Fixed in Windows 7 changing the font size in Message Box from Segoe UI 9px to 10px.

happysurf avatar Jun 10 '16 16:06 happysurf

Should we postpone adding new features until gtranslate is ported to WebExtension?

Has anyone started working on that yet?

fluks avatar Aug 03 '16 03:08 fluks

@fluks Not me. I didn't had time to look at it. I would like to try and play with the build tools (packaging, lint, cross browser support) before.

PerfectSlayer avatar Aug 03 '16 18:08 PerfectSlayer

@fluks @PerfectSlayer Same, I haven’t tried yet.

bpierre avatar Aug 14 '16 17:08 bpierre

Hello! Are you able to create a webextension with the actual build tools? thankee :)

S3ndG avatar Apr 22 '17 08:04 S3ndG

Hi @nemoload, This add-on is an Open Source software. Feel free to contribute and participate to the project as I did the past two years. Personally, I haven't migrate my own add-on that I develop since 2005 and I'm quite bored of the constant changes of framework and the need to rebuild from scratch. But it's nice to see hurry people. I just hope you will put as much energy to port the add-on than remind us to do it quickly. 🙇

PerfectSlayer avatar Aug 01 '17 16:08 PerfectSlayer

i'm looking into it today.

mote0230 avatar Aug 01 '17 18:08 mote0230

@PerfectSlayer I have no problem in working myself on this add-on. I use it on a daily basis and my web browsing experience depends on it. I'm only afraid if the original maintainers are already porting it and my work would be redundant.

akhal3d96 avatar Aug 01 '17 22:08 akhal3d96

ok i did some work, but it looks like there's some problems: Selected text is max 150 chars until ff 56 https://bugzilla.mozilla.org/show_bug.cgi?id=1338898 , making it half useless until then.

Next is there are no events available to notify us the context menu gtranslate item is being expanded, so best we can do is make a translate request to google every time some text is selected and the context menu is opened. This also requires a context-script that will always be watching for these things. I'd like to know what you guys think about this.

It also blocks lazy loading the to and from language lists, meaning that for performance reasons it will be 2 lists of languages, one for the "from" and one for the "to" language. https://bugzilla.mozilla.org/show_bug.cgi?id=1215376

Less important, no way to not show "translate page" on single images by looking at the mimetype, see https://bugzilla.mozilla.org/show_bug.cgi?id=1361447

There's a branch on my profile, but it's very much work in progress.

mote0230 avatar Aug 02 '17 12:08 mote0230

@nemoload ~~As far as I know, the original maintainer does not have a private development branch (in which he could have started a web-extension port).~~ But he has!

@mote0230 Thanks for your prototype! But it's sad to see the API are still not polished...

make a translate request to google every time some text is selected and the context menu is opened

For me, I will clearly be a no-go! I won't use an extension that will send to an external service provider any text I'm trying to copy through the context menu. But may be other are okay with this behavior… 😫

PerfectSlayer avatar Aug 02 '17 15:08 PerfectSlayer

Not working on it at the moment, if anyone wants to start, no problem for me!

I started some time ago to experiment with it, and the things I noted are:

  • As @mote0230 said, there was no way to update a menu after opening it, which is a big issue for this addon.
  • Minor issue, but there was no way to set a different icon than the addon icon. It appears to be fixed now: https://bugzilla.mozilla.org/show_bug.cgi?id=1321544

bpierre avatar Aug 02 '17 16:08 bpierre

And another issue that mozilla need to fix first: display the full text in a tooltip. https://bugzilla.mozilla.org/show_bug.cgi?id=1332270

mote0230 avatar Aug 10 '17 11:08 mote0230

And the guy from the context menu tooltip doesn't want to implement it. Only other way I could think of is this: image

mote0230 avatar Aug 12 '17 15:08 mote0230

@mote0230 Is that possible? I thought there was a length limitation.

bpierre avatar Aug 14 '17 09:08 bpierre

I opened a bug for the “onMenuOpen” event: https://bugzilla.mozilla.org/show_bug.cgi?id=1390061

bpierre avatar Aug 14 '17 09:08 bpierre

Yeah i put in a string split function for the max length and \n and then a loop to create the entries.

I don't really understand why you need the onMenuOpen. I think all we need is in https://bugzilla.mozilla.org/show_bug.cgi?id=1215376 ?

mote0230 avatar Aug 14 '17 10:08 mote0230

I don't really understand why you need the onMenuOpen.

There is no need, I missed this link. Closed 👍

bpierre avatar Aug 14 '17 10:08 bpierre

Hi,

This addon is great and it's the only reason I won't update to Firefox 57 yet. Is the porting work ongoing? I might be able to contribute, though only a few months later.

marczellm avatar Sep 28 '17 22:09 marczellm

Good afternoon, tell me please, but there is a branch or pull request with a change that could be collected and seen, tested.

Scaurus avatar Oct 10 '17 10:10 Scaurus

Maybe you can make something like this [1]? [1] https://addons.mozilla.org/firefox/addon/simple-translate/

def00111 avatar Oct 30 '17 15:10 def00111

Hi, Firefox 57 is here. I updated to this new version but I can't use your extension because is obsolete... Could you update it? Thanks

maicol07 avatar Nov 14 '17 14:11 maicol07

What if leave the same functionality as it was before WebExtentions, but if selected text is too long for menu item, add another submenu item that after clicking on it would show some really simple popup under selection right on the page? Or something like that, it just what came in my mind as a substitution for the context menu tooltips. And I don't know if it's reasonable to use for showing other translation options..

STeeL835 avatar Nov 18 '17 13:11 STeeL835

An update from the Mozilla Add-ons Twitter account:

Hey there! Bug 1215376 might be landing as early as FF 59. Unfortunately, bug 1332270 is a WONTFIX. We think there’s another way you can do that, though.

Want to get in touch? We’d love to talk more about workaround ideas - https://wiki.mozilla.org/Add-ons/developer/communication#Get_in_Touch

From https://twitter.com/mozamo/status/933394486859767810

bpierre avatar Nov 30 '17 10:11 bpierre