birchill / 10ten-ja-reader

A browser extension to translate Japanese by hovering over words.
https://addons.mozilla.org/firefox/addon/10ten-ja-reader/
GNU General Public License v3.0
605 stars 45 forks source link

Default to other dictionaries when longer word can be parsed #256

Closed nicolasmaia closed 4 years ago

nicolasmaia commented 4 years ago

For instance, when looking at 井の頭公園, rikai will only look at 井. But it would be more useful if it could detect a longer word and default to other dictionaries, like jmnedict.

birtles commented 4 years ago

Oh yes, I've wanted that before. If we find a longer match in the names dictionary, we could show that at the top of the list.

nicolasmaia commented 4 years ago

Ideally other dictionaries too, but I imagine that would have to wait until #41 is done.

I'm very excited with the prospect of perhaps using Wikidata as a names dictionary. Much more complete than JMnedict.

birtles commented 4 years ago

This should be fixed in the upcoming 0.2.0 release.

name-preview

It could still use a bit of work, however. For example, you can't highlight the name entry for copying to the clipboard.

nicolasmaia commented 3 years ago

Any ideas as to why ブラガ doesn't show the name Braga first?

nicolasmaia commented 3 years ago

Same issue with キンドル. It sounds like this might be a regression.

birtles commented 3 years ago

Yes, highly likely to be a regression since I had to rewrite that code to move it from the background page to the content script in order to support the tab feature. I'll look into it this afternoon. Thanks for reporting!

birtles commented 3 years ago

Actually I'm not sure if this is a regression after all. The reason those two words don't show previews is because the heuristic for showing a preview is that the match has some kanji characters. See the removed code here:

https://github.com/birchill/10ten-ja-reader/commit/b7f4233edebd33ac56abcf70c853063723fc09ea#diff-11db236acd6b02b1229e7d325e9bf8edb521032e6388f68b6a884ec24bbe291fL518-L541

That said, I'm not sure if the old code actually worked as expected (the condition it uses seems a bit odd). Furthermore the comment with the old code suggests we intended to show matches with katakana but not hiragana-only matches.

In https://github.com/birchill/10ten-ja-reader/commit/a3a60a807b1e83b991c99c22808005d4b20ef13e I've made it show katakana matches so now so those two example should show the preview correctly in the next release.