dialect-app / dialect

A translation app for GNOME.
https://dialectapp.org/
GNU General Public License v3.0
597 stars 69 forks source link

Directly translate the selected text with translation #347

Closed frkntlr closed 9 months ago

frkntlr commented 12 months ago

The text we choose can be added to the translation program with a shortcut and translated. It can work like Deepl and the gnome plugins I added below. Once we press the shortcut, the application comes to the fore and shows us the translation result. This is the result I have in mind. Example plugins;

https://extensions.gnome.org/extension/1756/text-translator/ https://extensions.gnome.org/extension/1849/screen-word-translate/

rafaelmardojai commented 12 months ago

This has been requested before, see #207 and #219. But we have rejected it because of limitations with Wayland.

But things have changed a bit, now we have a global shortcuts portal, and the GTK method for getting the selection clipboard (Gdk.Display.get_primary_clipboard) seems to be working on Wayland. I even did some experiments past year:

https://github.com/dialect-app/dialect/assets/6210397/28f6a4c2-501b-4e81-b429-80f55b0a091c

Thing is, that even having a global shortcuts portal, I'm nor sure how long will the primary clipboard getting method stay working, I need to investigate if it is working on GNOME for legacy reasons or if it is expected to stay working.

frkntlr commented 11 months ago

@rafaelmardojai That's very nice. Actually, what I mean is that it can translate the text we select by setting shortcuts like ctrl+F3. Eventually this application will work outside of gnome. There are actually tools that do this kind of functionality with addons. It should be very easily included in this application. If I were a software person, I would definitely want to support it. Sorry.

arrahhal commented 10 months ago

@rafaelmardojai It would be awesome if you could incorporate a command-line option --selection like how quick-lookup did. This addition would make it much simpler to configure the shortcut either through the GUI or any other way. I've tried Quick-Lookup on Wayland, and it woks great.

vesley commented 10 months ago

Having a global shortcut to activate dialect and translate the current selected text is the only reason why I'm using glate instead of Dialect. I'm using f.g. a clipboard manager and don't want to have all copied texts in it.

Dan-Master commented 10 months ago

I also use Glate to quickly translate selected text, and it handles it perfectly, without any extra steps and without clogging up the clipboard with all sorts of nonsense. If it will be possible to implement it in Dialect in the same way, it will be really fantastic.

rafaelmardojai commented 10 months ago

Yes, I plan to implement a --selection cli option to start Dialect with the primary clipboard contents copied soon.

Integration with the global shortcuts portal will have to wait a bit until it is fully integrated in libportal.