Fevol / obsidian-translate

Translate text and entire notes in Obsidian
MIT License
103 stars 6 forks source link

Feature Idea: Quick Cycle Possible Translations #29

Open chrisgrieser opened 2 years ago

chrisgrieser commented 2 years ago

Just an idea I had that could fits well with the plugin maybe?

So the plugin can already translate selected text into a different language. However, when I need to translate things, it's mostly more complicated words for which there are multiple possible translations.

What I could imagine would be to quickly cycle between the possible translations. So for example you select the word "grande" (french) and on the first run of the command, it becomes "big". run the command again, the word becomes "great", a third time, it becomes "tall".

That way, you could quickly cycle through possible translations (even without using the mouse) without having to look up all possible translations and then tediously copying or typing the translation you choose.

Fevol commented 2 years ago

Thanks for the feedback!

I've been looking around a bit to see what is possible. I found that most API's do not really have a method that allows you find synonyms/similar phrases for any input (only Azure seem to support this, and perhaps some of the Chinese services).

Maybe it would make sense to integrate with phibr0's Obsidian Dictionary to provide this feature? The user of the plugin would have to separately install and set this up too, though.

Side-question: in the DeepL web interface you can select a word to get its alternative translations, would this maybe be a good alternative for your suggestion? It's easier for me to implement, and it would be easier for the user to figure out how the functionality works.

image
Fevol commented 2 years ago

@chrisgrieser I've made a prototype of the DeepL-like synonym provider in a separate branch, if you wanted to check it out. It directly integrates with phibr0's obsidian-dictionary plugin, and will provide synonyms of the currently selected word.

However, I'm going to push this feature back to a later date, as I encountered multiple issues:

  1. Since most translator API's do not provide a way to get alternative sentences, alternative in-context translations will be hard to come by. The best alternative available currently is showing the synonyms of the translated word (be it with obsidian-dictionary or other API's that provide synonyms), but this doesn't consider sentence structure, grammar rules, etc.
  2. Implementing the context menu for showing the synonyms in a clean way proves to be harder it initially seems to be, due to some JS engine limitations

I'll keep looking around though, there might still be a solution possible!