Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Port to new WebExtension format #66

Open
PerfectSlayer opened this issue Apr 30, 2016 · 60 comments · May be fixed by #86
Open

Port to new WebExtension format #66

PerfectSlayer opened this issue Apr 30, 2016 · 60 comments · May be fixed by #86
Assignees

Comments

@PerfectSlayer
Copy link
Collaborator

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:

And some that could be easier with:

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 ?

@bpierre
Copy link
Owner

bpierre commented Apr 30, 2016

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/

@PerfectSlayer
Copy link
Collaborator Author

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! 😅

@bpierre
Copy link
Owner

bpierre commented May 16, 2016

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

@PerfectSlayer
Copy link
Collaborator Author

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

@bpierre
Copy link
Owner

bpierre commented May 18, 2016

Ah, I didn’t see that, cool!

@PerfectSlayer
Copy link
Collaborator Author

Yep, everything should be here to start a port 😉

@happysurf
Copy link

happysurf commented Jun 10, 2016

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.

@fluks
Copy link
Contributor

fluks commented Aug 3, 2016

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

Has anyone started working on that yet?

@PerfectSlayer
Copy link
Collaborator Author

@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.

@bpierre
Copy link
Owner

bpierre commented Aug 14, 2016

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

@S3ndG
Copy link

S3ndG commented Apr 22, 2017

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

@akhal3d96
Copy link

@PerfectSlayer
Copy link
Collaborator Author

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. 🙇

@mote0230
Copy link
Collaborator

mote0230 commented Aug 1, 2017

i'm looking into it today.

@akhal3d96
Copy link

@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.

@mote0230
Copy link
Collaborator

mote0230 commented Aug 2, 2017

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.

@PerfectSlayer
Copy link
Collaborator Author

PerfectSlayer commented Aug 2, 2017

@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… 😫

@bpierre
Copy link
Owner

bpierre commented Aug 2, 2017

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:

@mote0230
Copy link
Collaborator

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
Copy link
Collaborator

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

@bpierre
Copy link
Owner

bpierre commented Aug 14, 2017

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

@bpierre
Copy link
Owner

bpierre commented Aug 14, 2017

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

@mote0230
Copy link
Collaborator

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 ?

@bpierre
Copy link
Owner

bpierre commented Aug 14, 2017

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

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

@marczellm
Copy link

I created a basic port at https://github.com/marczellm/gtranslate/tree/webextension. If someone is reading this, maybe you could check it out, look for bugs and missing functionality before I do a pull request.

What it cannot do because of missing APIs:

  • Display translation of right-clicked link text in context menu (like it does with translated selection)
  • Tooltips

What it does differently:

  • Language selection lives under addon settings, not in the context menu (I think it’s a better place for that)

@marczellm
Copy link

You can test it on latest Firefox Nightly. Features to the menus.onShown API are still being added.

@maicol07
Copy link

@marczellm how to install it?

@marczellm
Copy link

marczellm commented Feb 25, 2018 via email

@maicol07
Copy link

Does it work on Firefox 58.0.2?

@marczellm
Copy link

marczellm commented Feb 25, 2018 via email

@maicol07
Copy link

Ah..

@fluks
Copy link
Contributor

fluks commented Feb 25, 2018

Works. @mote0230 mentioned a way to show a longer text, maybe that could be integrated? Now if the selected text is long, it only shows "Fetching translation...".

@marczellm
Copy link

marczellm commented Feb 25, 2018 via email

@mote0230
Copy link
Collaborator

Starting from @marczellm 's code, i fixed the multiline as in the screenshot in #66 (comment) , and enabled alternative translation and dictionary stuff for single words by default, since i couldn't quickly figure out the options and i have to go outside now.
Remember that it still sends your selection to google every time you have text selected and right click.
https://github.com/mote0230/gtranslate/tree/webextension

@marczellm
Copy link

I fixed the long text problem

@marczellm
Copy link

Dear @bpierre,

Firefox 60 launches on 09 May.
I have ported gtranslate to WebExtension minus the tooltip functionality. @mote0230 implemented a workaround: the description lines can be displayed as a list of noop context menu items.

Would you like us to create a pull request so that you can release the WebExtension version as an update to the existing addon, or should we release it separately, named gtranslateWE or similar? (as happened to some other addons)

@marczellm
Copy link

(@mote0230, I intend to pull your changes into my fork and polish its relations to the options screen, but only after 09 May)

@marczellm marczellm linked a pull request May 9, 2018 that will close this issue
@achernyakevich-tch
Copy link

Concerning to comment of @mote0230:

Remember that it still sends your selection to google every time you have text selected and right click.
https://github.com/mote0230/gtranslate/tree/webextension

I have just added my comment to the pull request #86, probably it will be more correct to add it here:

Maybe desired feature could be achieved by slight change of user behavior. For example, the following case could be valuable for me:

  • I do some selection on screen
  • I make right click
  • context menu is displayed
  • I navigate to gTranslate's menu item Translate ...
  • I click this menu item
  • on click extension will call Google Translate service, build next level submenu and show to me required information

So difference is only "click/press Enter" vs "on mouse over/selection item by keyboard".

From other side it will completely avoid problem of sending of selection to Google every time when context menu is called.

@marczellm
Copy link

@achernyakevich Correct me if I'm wrong, but I think if you click any menu item, the menu is dismissed

@achernyakevich-tch
Copy link

@marczellm

I have just tested in my FF 56.0.2 and in FF 59.0 - in both cases if menu item contained submenu then click caused no collapsing but opening of a submenu.

I can't perform more reliable checking for case when menu item does not contain submenu items and by clicking it will build submenu and will prevent collapsing of menu in general. But I can expect that return false for the even handler could reasonably prevent collapsing of menu. I think you could easily test by small peace of code (sorry, I have no infrastructure for web-extensions development).

In any case, gTranslate already has some submenu. So if we will be able to catch click/press Enter then we could try to rebuild submenu. Having "..." or "(click this item)" text in menu item we could inform user to make a click/press Enter.

@marczellm
Copy link

@achernyakevich

  • return false does not prevent menu dismissal.
  • Cannot catch a click on a menu item that has a submenu.
  • You don't need infrastructure, only a text editor.

@mote0230
Copy link
Collaborator

The WebExtensions APIs triage for https://bugzilla.mozilla.org/show_bug.cgi?id=1440635 was today , they approved it, and I think they said it shouldn't be too difficult to implement since it's a variation of what is already there. This should mean gtranslate will be able to run in nightly soonish.

@exie-czex
Copy link

is this project definitely dead or still waiting for some APIs to be implemented?

@marczellm
Copy link

marczellm commented Nov 9, 2018 via email

@rodrigokfw
Copy link

Please don't let this die
Cannot access:
https://addons.mozilla.org/Firefox/Addon/gTranslate/

@slava-uxd
Copy link

I don't know the state of dev's on this, but as a user I'm still waiting, thinking of how great gTranslate used to be every time I translate something. As an IT guy I get periodically asked "Is the new version out yet?"

@PerfectSlayer
Copy link
Collaborator Author

@marczellm Doesn't latest versions of Firefox it with API improvement?
@bpierre Are you aware the add-on is no more listed on AMO?

@bpierre
Copy link
Owner

bpierre commented Jan 11, 2019

@PerfectSlayer Ah no I didn’t know… it’s marked as “incomplete”:

image

So I imagine it will be relisted whenever a new version will be published.

I was checking again:

The tooltip issue is not strictly required to make it work: it just means that we’ll have to click in order to see the full translation of long sentences.

But I agree with @mote0230 that sending every selected text to Google servers is not acceptable.

@marczellm do you know more about the current status of the WebExtensions API?

@mote0230
Copy link
Collaborator

mote0230 commented Jan 11, 2019

confirm, depends on https://bugzilla.mozilla.org/show_bug.cgi?id=1440635

https://github.com/marczellm/gtranslate/tree/webextension here's also a working version minus the privacy thing with selected text + rightclick.

@marczellm
Copy link

Maybe someone of us should go and do the needed improvements in Firefox. It's an open source project after all.

@rodrigokfw
Copy link

rodrigokfw commented Mar 13, 2019

confirm, depends on https://bugzilla.mozilla.org/show_bug.cgi?id=1440635

https://github.com/marczellm/gtranslate/tree/webextension here's also a working version minus the privacy thing with selected text + rightclick.

Thank you very much,

a question: How do I install this version in Firefox non-developer?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.