linguist icon indicating copy to clipboard operation
linguist copied to clipboard

[Feature request] Add shortcuts to extension

Open wordpure opened this issue 2 years ago • 14 comments

Such as the following examples.

  • Switch between the original and the translation of the page
  • Show text translation window
  • Activate toolbar button(for Firefox users)
  • Read the selected text aloud
  • Translate the selected text

wordpure avatar Jun 30 '22 03:06 wordpure

It's may be useful for people. We have to think about implementation.

  • [ ] Think about hotkeys for each feature
  • [x] What difference between "Show text translation window" and "Translate the selected text"? We can't show empty window for translate selected text. And we can't open extension popup if you about it. We may open new browser tab contains extension page, but first we have to implement standalone page with text translator
  • [ ] When we aloud selected text, we have to render a control to stop speaking. We have to think about UI for this case

What you mean under "Activate toolbar button"?

vitonsky avatar Jun 30 '22 08:06 vitonsky

What you mean under "Activate toolbar button"?

Chromium assigns a shortcut to each extension to activate their buttons in the toolbar, but Firefox does not, so users must manually click to trigger them.

What difference between "Show text translation window" and "Translate the selected text"? We can't show empty window for translate selected text. And we can't open extension popup if you about it. We may open new browser tab contains extension page, but first we have to implement standalone page with text translator

https://user-images.githubusercontent.com/68013962/176665197-065077e8-38fe-4fe6-b768-238fcebe83e5.mp4

This video is what I expected it to be.

When the text is not selected, press the shortcut key, and the user can input freely. When the text is selected, press the shortcut key, and the selected text is used as input.

Previously I hadn't realized the problem you pointed out, so hopefully it will get rid of the toolbar and be implemented in a popup box in the mouse position.

Now think about it, whether it's possible to refer to the implementation of ContextSearch-web-ext in Firefox, using only one shortcut key to implement "Activate toolbar button" "Show text translation window" and "Translate the selected text"?

When we aloud selected text, we have to render a control to stop speaking. We have to think about UI for this case

I have an idea I don't know if it will work.

  • When the text is selected, press the shortcut key to read the original text aloud
  • While reading aloud, press the shortcut key to stop the reading
  • While reading aloud, select the new text and press the shortcut key to stop the original reading and start a new one

wordpure avatar Jun 30 '22 11:06 wordpure

Aloud text by hotkeys is good idea! Your description sounds good. I want to implement this feature asap. I have to think about language for speaking text and about indication of loading TTS data. Do you have ideas about? We would allow to configure in settings a target language for aloud text by hotkey, but how we can indicate that linguist is load some data for TTS and user should wait sometime? I think that we have to avoid render additional elements on the page (like spinner).

Hotkey to insert text into the tab for translate text it's good idea too. I will research this ability. If it possible not for all browsers, i would mark it as feature with low priority, because users should feel the same experience for all browsers.

p.s. I like your suggestions, it's really interesting! I be honest to say that i will try to not overload features a Linguist, it's not a tool that will do all things in the world, but i will implement most powerful features which users needs, so feel free to suggest all that you need. Maybe it will not implement today, but i will plan it. I expect that community will decide which features Linguist must have

vitonsky avatar Jun 30 '22 20:06 vitonsky

We would allow to configure in settings a target language for aloud text by hotkey

Perhaps we can provide two shortcuts, one for reading aloud the selected text and another for reading aloud the translation of the selected text (the target language is user-configurable).

Pronunciation is always confusing for a foreign language learner. When reading foreign language articles, if we can read the selected text aloud repeatedly with the help of linguist, it will be very helpful for learning.

but how we can indicate that linguist is load some data for TTS and user should wait sometime? I think that we have to avoid render additional elements on the page (like spinner).

Maybe we can change the mouse style to loading?

If it possible not for all browsers, i would mark it as feature with low priority, because users should feel the same experience for all browsers.

You're right, I had a similar experience earlier and that does tend to confuse and even annoy users.

p.s. I like your suggestions, it's really interesting! I be honest to say that i will try to not overload features a Linguist, it's not a tool that will do all things in the world, but i will implement most powerful features which users needs, so feel free to suggest all that you need. Maybe it will not implement today, but i will plan it. I expect that community will decide which features Linguist must have

Glad my advice inspired you.

I will continue to be involved in the community of linguist, and work with everyone to make linguist better.

Thank you for your great work on this extension.

wordpure avatar Jul 01 '22 04:07 wordpure

  • Switch between the original and the translation of the page

I really agree, I haven't found an extension on Chrome that can be switched with shortcut.

7peanuts avatar Jul 20 '22 05:07 7peanuts

I haven't found an extension on Chrome that can be switched with shortcut.

FilipePS/Traduzir-paginas-web

This extension works, but it is not published in the Chrome Web Store and needs to be installed manually.

wordpure avatar Jul 20 '22 09:07 wordpure

FilipePS/Traduzir-paginas-web

This extension works, but it is not published in the Chrome Web Store and needs to be installed manually.

真不错,我在火狐上也是用的这个,没仔细看还有 Chromium 版的 👍 可以打包成 crx,使用更方便 😍

7peanuts avatar Jul 20 '22 13:07 7peanuts

Activate toolbar button(for Firefox users)

I have opened #341 for this.

WofWca avatar Apr 30 '23 13:04 WofWca

@WofWca consider this issue not just about hotkey to open extension popup.

Requested features in this issue

  • [ ] Implement hotkey to start TTS
  • [ ] Hotkeys to: open popup, toggle tab to "Text translation", focus textarea
  • [ ] Hotkeys to only open popup

Also, keep in mind that any hotkeys must be configured by user on preferences page

vitonsky avatar Apr 30 '23 13:04 vitonsky

this issue not just about hotkey to open extension popup

I understand

any hotkeys must be configured by user on preferences page

commands bindings can be configured in Chromium as well as in Gecko, but not directly on the options page, although you can link the shortcuts page from your options page, like I did:

image

Also Gecko supports the commands.update API, and you can update the commands programmatically.

Do you want them to be specifically configurable through the options page alone?

WofWca avatar Apr 30 '23 13:04 WofWca

commands vs keydown listeners (like in #274).

commands advantages:

  • Can be global (supported only in Chromium for now) (i.e. you can execute a shortcut without the browser being in focus, see Chrome docs).
  • Can be executed without waiting for the content script to get loaded
  • Built-in browser support to bind / rebind (i.e. to another key combination) / unbind shortcut.

commands disadvantages:

  • Less granular control, e.g. you can't have single-button shortcuts (like "A", "S", "D", etc.). For reference, this is the main reason why I decided to go for keydown in my extension for most (not all) shortcut-able functions.
  • I thought there is a limited amount of them (like 10 or something) you can specify in Chromium, but I can't find this info now. Maybe it's gone since Manifest V3?
Side note

Keep in mind that the commands API is not implemented in Gecko for Android. I ran into this https://github.com/WofWca/jumpcutter/issues/122#issuecomment-1528720999

WofWca avatar Apr 30 '23 13:04 WofWca

@WofWca it looks commands API are not cross-platform, but Linguist are cross platform extension, so we have to implement hotkeys another way.

It's ok that android does not support commands API, but if we can't programmatically change key bindings for all platforms (both chromium and firefox), then we cannot to use commands API.

vitonsky avatar Apr 30 '23 13:04 vitonsky

if we can't programmatically change key bindings for all platforms (both chromium and firefox), then we cannot to use commands API

I don't think it's that important of a thing to change key bindings directly on the extension's options page instead of a built-in browser page. Definitely not to an extent that it's better to keep it impossible to open the popup with a shortcut in Gecko.

WofWca avatar Apr 30 '23 14:04 WofWca

@WofWca i agree with you about shortcut to open extension popup, so we can research suit shortcuts combination and use command API to implement this feature.

But other features like "Hotkeys to: open popup, toggle tab to "Text translation", focus textarea" must be implemented another way.

vitonsky avatar Apr 30 '23 14:04 vitonsky

Hi there, big fan of your add-on! Works really well.

I regularly open the pop-up panel for translating manually inputted text, by pressing the toolbar button in Firefox. Being able to set a keyboard shortcut in about:addons to open the pop-up panel or trigger the toolbar button would save me a few milliseconds each time I use your add-on. Thanks for considering!

rubcap avatar Dec 06 '24 09:12 rubcap