goldendict / goldendict

A feature-rich dictionary lookup program, supporting multiple dictionary formats (StarDict/Babylon/Lingvo/Dictd) and online dictionaries, featuring perfect article rendering with the complete markup, illustrations and other content retained, and allowing you to type in words without any accents or correct case.
http://goldendict.org/
Other
5.92k stars 730 forks source link

[New Release] Anki integration, Google Images & Japanese Improvements with Add-on set #1352

Open kanjieater opened 3 years ago

kanjieater commented 3 years ago

As there's no longer a forum and GitHub Discussions aren't enabled, I was hoping we could still talk about new features in GoldenDict & add-ons here.

I've recently made a suite of programs and installation video here: https://www.youtube.com/playlist?list=PLV9y64Yrq5i-1ztReLQQ2oyg43uoeyri-

You can see the source here: https://github.com/kanjieater/GoldenDict-Toolbelt

You could use the Google Images, Anki part, and other program separately if you wanted

These tools can do things like:

  1. Full phrase deinflection ( not just single words) & Jisho's recommendations
  2. Google Auto Correct
  3. Frequency list that tells you which reading is most popular (migaku doesn't know the readings)
  4. Automatically do a custom search in anki - essentially turning a sentence bank into an dictionary of example sentences.
  5. Automatically add Images, Audio, or Text from the clipboard to the appropriate field from any app with a global hotkey
  6. Google Images

Enjoy!

lionslancer commented 3 years ago

Hi! Nice work on the add-on. Noticed a couple of issues while during set-up though.

  1. Anki currently uses double quotes for searches, and will automatically add them when searching in the browser. If a search is done with single quotes, double quotes will be placed around them. This means that the [single quotes inside double quotes]-syntax currently used for the search parameter will not work if a deck name contains whitespace. Using double quotes inside of single quotes would probably solve this.
  2. anki-img.png and copy-img.png do not load properly when viewing an article. Inspecting shows the filepath as file:///C:/Users/MyUser/AppData/Roaming/Anki2/**MyUser**/addons21/247820692/assets/images/_anki-img.png which is incorrect since Anki doesn't store extensions per profile. Manually deleting **MyUser** from the filepath during inspection will cause the images to load properly.

Also, just as a tip, you can place qt-style.css alongside article-style.css in a theme folder and use different qt-styles per theme, although the application still needs to be reloaded for this to take effect.

kanjieater commented 3 years ago

Hi! Nice work on the add-on. Noticed a couple of issues while during set-up though.

  1. Anki currently uses double quotes for searches, and will automatically add them when searching in the browser. If a search is done with single quotes, double quotes will be placed around them. This means that the [single quotes inside double quotes]-syntax currently used for the search parameter will not work if a deck name contains whitespace. Using double quotes inside of single quotes would probably solve this.
  2. anki-img.png and copy-img.png do not load properly when viewing an article. Inspecting shows the filepath as file:///C:/Users/MyUser/AppData/Roaming/Anki2/**MyUser**/addons21/247820692/assets/images/_anki-img.png which is incorrect since Anki doesn't store extensions per profile. Manually deleting **MyUser** from the filepath during inspection will cause the images to load properly.

Also, just as a tip, you can place qt-style.css alongside article-style.css in a theme folder and use different qt-styles per theme, although the application still needs to be reloaded for this to take effect.

  1. Check out the examples here and see if that works for you: https://github.com/kanjieater/GoldenDict-Toolbelt/blob/temp/README.md#example-2 So despite single quotes not working in Anki, you must use single quotes for the addon. BUT the goldenDict addon will convert them to double quotes so that it works in Anki.

The reason for this is that command line parameters in windows didn't work as double quotes, and within the last year Anki made that update to only accept double quotes in search. It's a little hacky, but it does work for me and I have spaces in my deck names.

  1. You're right. I have a junction to the addons in my user profile for some reason, so I wasn't seeing that. Temporarily you could place the file where the program is expecting it to get it working. Or like I have, just junction addons from their location to your profile folder until I fix it. Here's a free post & guide for setting up junctions easily: https://www.patreon.com/posts/syncing-anki-add-30894998

  2. I didn't know that! Thanks for the tip.

kanjieater commented 3 years ago

I've fixed a few of the issues and the update is uploading to ankiweb now! The update that fixes the pathing issue you mentioned & combines the css files into a single folder (you could set up a junction here to the actual goldenDict styles folder to have it automatically kept up to date.

This is a major update and expects a newer version of GoldenDict to be installed. Make sure to install the latest Goldendict QT 5 windows beta from: https://sourceforge.net/projects/goldendict/files/early%20access%20builds/Qt5-based/64bit/GoldenDict-1.5.0-RC2-372-gc3ff15f_%28QT_5123%29%2864bit%29.7z/download By doing this we can now support webp images as well (yay!).

Make sure to copy over the updated CSS. This also expects yugothic.ttf (from addons21\247820692\assets\fonts) to be installed.

lionslancer commented 3 years ago

I've got everything working now, thanks!

I also thought of a couple other things that could be worth sharing:

  1. I found this blog post about styling GoldenDict. It's in Chinese, but I ran it through DeepL and it covers a lot of useful properties. With it, I was able to update the qt-style.css for the dark mode to fix things like the "History" and "Found in Dictionaries" labels not being visible. I've attached that file so feel free to use it if you like it. The only thing missing from what I can tell is a white version of the "Add to Favorites"-button, but I don't know if there's any way to fix that.

File: qt-style.zip

  1. This repository contains Hunspell morphology dictionaries for Japanese that enable native deinflection in GoldenDict.

  2. Did you see my last reply in #1334? In short, I think you can get the Hiragino font working by leaving out W2 from the name.

  3. I noticed a couple of small things in article-style.css. There are a couple of typos (font-stye => font-style, vertical-alignment => vertical-align). You could also list preferred fonts like below instead of overriding the font-family property multiple times.

    body, h3, h2, pre {
    font-family : 'Yu Gothic', 'MS UI Gothic', 'MS Gothic';
    }

There are a couple things I'm having trouble with though.

I added the snippet below to article-style.css on my machine in order to keep the text from being right at the edge of the window and to line it up better with the rest of the dictionary entries. It works for word definitions but I don't know how to style the welcome page.

.sdct_m {
  margin-left: 10px;
  margin-right: 10px;
}

Also, most fonts in GoldenDict end up looking very jagged for me. Yu Mincho is one of the few exceptions. Have you noticed this, and if so, do you know of a way to fix it?

kanjieater commented 3 years ago

I've got everything working now, thanks!

I also thought of a couple other things that could be worth sharing:

  1. I found this blog post about styling GoldenDict. It's in Chinese, but I ran it through DeepL and it covers a lot of useful properties. With it, I was able to update the qt-style.css for the dark mode to fix things like the "History" and "Found in Dictionaries" labels not being visible. I've attached that file so feel free to use it if you like it. The only thing missing from what I can tell is a white version of the "Add to Favorites"-button, but I don't know if there's any way to fix that.

File: qt-style.zip

  1. This repository contains Hunspell morphology dictionaries for Japanese that enable native deinflection in GoldenDict.
  2. Did you see my last reply in #1334? In short, I think you can get the Hiragino font working by leaving out W2 from the name.
  3. I noticed a couple of small things in article-style.css. There are a couple of typos (font-stye => font-style, vertical-alignment => vertical-align). You could also list preferred fonts like below instead of overriding the font-family property multiple times.
body, h3, h2, pre {
  font-family : 'Yu Gothic', 'MS UI Gothic', 'MS Gothic';
}

There are a couple things I'm having trouble with though.

I added the snippet below to article-style.css on my machine in order to keep the text from being right at the edge of the window and to line it up better with the rest of the dictionary entries. It works for word definitions but I don't know how to style the welcome page.

.sdct_m {
  margin-left: 10px;
  margin-right: 10px;
}

Also, most fonts in GoldenDict end up looking very jagged for me. Yu Mincho is one of the few exceptions. Have you noticed this, and if so, do you know of a way to fix it?

  1. I looked around for a JP hunspell dict forever! Thank you for finding one. I'll try that out now. The Jisho bit is still useful for sentences and finding phrases or words that might be on Wikipedia. UPDATE: It does seem like it could be useful for offline use, but usually Jisho seems to do a pretty good job. The hunspell dict gives a lot of options, which end up being kind of noisy sometimes. And in some cases just wrong: It corrected 鵜呑み (which is correct & has results) to 鵜吞み. 呑!=吞, and is wrong. Or try 芳しかった (Jisho deinflects it right but hunspell doesn't). Still a cool tool to play around with.
  2. I did. I ended up switching to yu mincho, for the reason you mentioned - it's not jagged. So no, I'm in the same boat. But I think yu mincho is a fine font so I'm sticking with it.
  3. Yeah, honestly that code is pretty slapped together. I did multiple blocks for the fonts so i could try a bunch out and never cleaned it up.

Anyways, good find with all of this. I really appreciate it. I might clean up the styles and add a better dark theme in the future, but it's not really too high of a priority. Feel free to PR anything you'd like to share though or keep posting here 👍.

epistularum commented 2 years ago

And in some cases just wrong: It corrected 鵜呑み (which is correct & has results) to 鵜吞み. 呑!=吞, and is wrong.

吞 is the actual correct form of 呑, it's just that most people use the former. Similarly, 噓 is the correct form of 嘘. From the 大漢和辞典: image

kanjieater commented 2 years ago

I believe this falls into the "technically correct but obsolete" category.

Honestly I don't even think I'd consider that to be technically correct considering you can't find something like 鵜吞み in use with any modern dictionary

epistularum commented 2 years ago

It's actually exclusively used in quite a few more recent dictionaries. I believe the reason that older dictionaries use 呑 instead is due to older Japanese encoding standards not supporting the right forms (namely JIS X 0208). Perhaps the dictionaries you are citing are converted from epwing (the vast majority of yomichan dicts are) which is a very old format that doesn't support unicode.

This is actually more common than you'd think. Famous examples that are present within the 常用漢字表 are:

𠮟 塡 剝 頰

叱 填 剥 頬

image

kanjieater commented 2 years ago

image image

Clicking on links like weblio's 吞 it shows the relevant version: https://www.weblio.jp/content/%E9%B5%9C%E5%90%9E%E3%81%BF

Still, this is interesting so thanks for sharing. Maybe I need some upgraded epwings. Though I'd still just prefer to use modern & relevant kanji whenever possible and know when a cleverly disguised obsolete kanji has sneaked in. Per your example, looking into some of your examples certainly some of these kanji are more common than others - and maybe obsolete or wrong isn't fair..

kanjieater commented 1 year ago

In case anyone else runs into issues running this, I had an issue recently where the QT5 64bit version linked above stopped working out of nowhere. The QT4 version still worked of the same rev. I got it working again by running it in Compatibility mode with Windows 7. I'm still on windows 10 64bit, fyi.

Update: Scratch that, I'm on windows 11 now, and it doesn't need compatibility mode but it does need to be run as admin. Not sure why...