ThijmenDam / BarTranslate

🚀 BarTranslate, a handy (free) menu bar translator widget for macOS.
https://thijmendam.github.io/BarTranslate/
GNU General Public License v3.0
171 stars 6 forks source link

Add DuckDuckGo Translation Service #45

Open 6502c opened 3 months ago

6502c commented 3 months ago

Hello,

would it be possible to add the DuckDuckGo translation service?

https://duckduckgo.com/duckduckgo-help-pages/results/translation/

That would be very much appreciated.

ThijmenDam commented 3 months ago

Hi @6502c,

Thanks for your suggestion.

DuckDuckGo does not provide a dedicated translation page like Google and DeepL (e.g. translate.google.com). Instead, DuckDuckGo integrates their translation service in their search engine. For example, the DDG translation window appears when you provide for a search query such as "translate X Y Z".

Fortunately, the DDG translation element already appears when we query for "translate", e.g. https://duckduckgo.com/?q=translate. So yes, I think it is possible to integrate DDG as long as we include "translate" as the default search query.

We probably need a decent amount of CSS to remove all redundant HTML elements (i.e. all elements except the translation window). Because all injected CSS is still included in the BarTranslate app instead of being hosted externally (which would allow CSS changes on the fly), I prefer to focus on #20 first, and then include DuckDuckGo.