gtranslate
gtranslate copied to clipboard
Port to new WebExtension format
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 ?
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/
As far I could see, all the API are here:
- context memu
- i18n (to get current locale)
- storage (to save settings)
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! 😅
I checked the contextMenus
API, and it looks like there is no support for nested menus at the moment.
I think you just have to add a parentId in the createProperties object.
Ah, I didn’t see that, cool!
Yep, everything should be here to start a port :wink:
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.
Should we postpone adding new features until gtranslate is ported to WebExtension?
Has anyone started working on that yet?
@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.
@fluks @PerfectSlayer Same, I haven’t tried yet.
Hello! Are you able to create a webextension with the actual build tools? thankee :)
Starting from Firefox 57, WebExtensions will be the only supported extension type. Desktop Firefox and Firefox for Android will not load other extension types. Shouldn't we hurry a little bit in porting it to the new api?
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. 🙇
i'm looking into it today.
@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.
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.
@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… 😫
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
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
And the guy from the context menu tooltip doesn't want to implement it. Only other way I could think of is this:
@mote0230 Is that possible? I thought there was a length limitation.
I opened a bug for the “onMenuOpen” event: https://bugzilla.mozilla.org/show_bug.cgi?id=1390061
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 ?
I don't really understand why you need the onMenuOpen.
There is no need, I missed this link. Closed 👍
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.
Good afternoon, tell me please, but there is a branch or pull request with a change that could be collected and seen, tested.
Maybe you can make something like this [1]? [1] https://addons.mozilla.org/firefox/addon/simple-translate/
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
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..
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