XapaJIaMnu / translateLocally

Fast and secure translation on your local machine, powered by marian and Bergamot.
MIT License
507 stars 29 forks source link

Provide macOS service to translate selection system wide #27

Open jelmervdl opened 3 years ago

jelmervdl commented 3 years ago

To provide better integration with macOS², it would be useful if the app could provide a menu item to the system wide "Services" menu*. Something like "Translate with translateLocally…" when text is selected.

Related docs:

¹ Incidentally, since Qt uses its own context menu for textfields, it won't work in any Qt app on macOS. It only seems to work in anything based on AppKit. So even macOS's own "News" only provides it in places where AppKit widgets are used… ² I hope other systems might provide similar functionality? Maybe through an MS Word plugin?

kpu commented 3 years ago

I feel like an MS Word plugin is one of those lines academics draw on how far we're willing to go with free integration and straying from research. Charging money or an undergrad project.

XapaJIaMnu commented 3 years ago

This seems like "Very nice to have but a lot of work." I second undergrad projects

jelmervdl commented 3 years ago

Hahaha. Okay. I have a feeling the implementation for a macOS service is pretty close to the thing you need to do to support drag & drop on the application icon in the Dock anyway, so maybe that's something that's within reach at some point.

Plugins for Word, and figuring out the mess that's the Linux Desktop Ecosystem, sounds indeed a bit farfetched.

jerinphilip commented 3 years ago

figuring out the mess that's the Linux Desktop Ecosystem, sounds indeed a bit farfetched

I have plans of some daemon/service/bus and hook ibus or something for outbound translation. I think it'll be glorious if it works.

jelmervdl commented 3 years ago

Update: I have a working prototype of this for macOS: https://github.com/jelmervdl/translateLocally/tree/macos-services

XapaJIaMnu commented 3 years ago

My only pain is that the MacOS version will have more features than the linux version xD

jerinphilip commented 3 years ago

My only pain is that the MacOS version will have more features than the linux version xD

How would we do this? dbus is a good idea?

jelmervdl commented 3 years ago

My only pain is that the MacOS version will have more features than the linux version xD

In this particular case, it's because MacOS is the only operating system that supports this kind of interaction between apps by design.

Nautilus and Dolphin seem to have a similar Service menu, but that's only for files I suppose. The only other solution I can think of is a global hotkey, but I don't know how that would get the selected text.

XapaJIaMnu commented 3 years ago

No idea, honestly, someone more experienced with windows GUI could do this.

I imagine it'd have to be a per toolkit solution with GTK apps using one codepath and QT apps using another, and whatever other toolkits there are using whatever other codepath...