Skip to content

Instantly share code, notes, and snippets.

@shoui520
Last active May 19, 2024 20:11
Show Gist options
  • Save shoui520/25460fd2e9fb194d3e5152fa2ce42ca2 to your computer and use it in GitHub Desktop.
Save shoui520/25460fd2e9fb194d3e5152fa2ce42ca2 to your computer and use it in GitHub Desktop.
Chinese Yomichan Setup

Yomitan setup for Chinese

https://learnjapanese.moe

Yomitan (formerly Yomichan) is a browser extension created for Japanese which enables its users to quickly and efficiently look up words on a webpage.
While it is made for Japanese, it is possible to use it for other languages, including Chinese.

Getting Yomitan

Yomitan is available for both Chromium and Firefox based browsers. You can find the respective versions below.
Chrome Web Store
Firefox Add-Ons
Once installed, it will open a new tab page, just close it for now so we don't confuse each other.

Dictionaries

Before you can use Yomitan, you must load dictionaries into it. The dictionaries listed on Yomitan's webpage are for Japanese, however there are some custom made ones for Chinese.

You can download them below. Thanks to Chrono07 at Refold for making the monolingual ones.
These come in .zip extension and are not to be extracted by the user.

Yomitan Dictionaries for Chinese - Google Drive

Installing dictionaries and basic usage

  1. Click on the yomichan-icon icon in the browser toolbar.
  2. Click on the cog icon to access the settings page.
  3. On the left sidebar, click on "Dictionaries" and then click on "Configure installed and enabled dictionaries…"
  4. Click the "Import" button on the bottom.
  5. Here's where you select the dictionaries to import. Have a read of some of the popular dictionaries, there may be more documentation available here.
  • [ZH-EN] CEDICT.zip - This is a popular Chinese to English bilingual dictionary, it is the dictionary used in many ZH-EN dictionary projects such as Pleco and Zhongwen. Matches both simplified and traditional.

  • [ZH-JA] 中日大辞典 第二版.zip - Chinese to Japanese bilingual dictionary. Do not import if not a speaker of Japanese. Matches only simplified.

  • [ZH-ZH] 兩岸詞典.zip - Monolingual dictionary that has "mainland definitions". It is rather small, though. Matches both simplified and traditional.

  • [ZH-ZH] 漢語大詞典.zip - Monolingual dictionary. Hanyu Da Cidian, the largest Chinese dictionary, with over 600k word entries, first published 1986-1994. Matches both simplified and traditional.

  • [ZH-ZH] 萌典国语辞典 (简体字) - (Moedict) Monolingual dictionary. From an online dictionary website that takes definitions from the Ministry of Education (MoE) of Taiwan. Overall the best choice as it has the most compound words. Matches both simplified and traditional.

  1. Please wait for the dictionaries to import. This could take a while if you are using a mechanical hard drive.
  2. Once complete, you can test Yomitan by holding down the Shift key and hovering over Japanese text. Here is a sample: 中文. It will display a pop up box displaying the definitions separated by dictionary.
    Click anywhere outside of the box or press the Esc key to dismiss.

The audio button is meant to play the word pronounced by a native speaker, but by default, Yomitan does not support audio for Chinese. But we can just add it.

Audio

TTS

We recommend using Microsoft Edge because it has free TTS built in that supports Microsoft Azure's neural voices.

Simply install Yomitan on Microsoft Edge and in the Yomitan audio settings -> Configure audio playback sources, delete the existing options and create sources of type Text-to-speech and choose your favorite voices, for example Microsoft Yunxia Online (Natural) - Chinese (Mainland) (zh-CN) for Mandarin.

Forvo

You can use the Yomitan Forvo Server anki add-on to enable Yomitan to play native audio from Forvo.

It is an add-on originally made for Japanese but it has the functionality to change the language.

First you need to add the add-on: https://ankiweb.net/shared/info/580654285

Restart Anki, then go back to your addons and double click Yomitan Forvo Server to open the settings menu.

Change the language from ja to zh

For Cantonese, change it to yue. Please note that this will only affect audio so readings will remain in Pinyin.

Now restart Anki again to apply changes.

In Yomitan settings, go in Audio and click configure audio sources. Remove everything and add a Custom URL JSON http://localhost:8770/?expression={expression}&term={term}

It should just work. You should also enable the automatic playback of audio in Yomitan too.

Forcing Chinese font

In the case that your fonts are not displaying in Chinese (e.g. the 绞丝 looks like the Japanese variant), you will need to force it with CSS.

Please refer to Yomitan CSS for Non-Japanese CJK Languages for instructions on fixing this.

On Windows you have the following possible fonts by default:

Simplified

DengXian
FangSong Regular
KaiTi Regular
Microsoft YaHei
Microsoft YaHei UI
NSimSun Regular
SimHei Regular
SimSun Regular
SimSun-ExtB Regular

Traditional

Microsoft JhengHei
Microsoft JhengHei UI
MingLiU_HKSCS-ExtB Regular
MingLiU-ExtB Regular
PMingLiU-ExtB Regular

@takti92
Copy link

takti92 commented Aug 15, 2022

Thank you! Works like a charm - same problem with the audio though!

@shoui520
Copy link
Author

shoui520 commented Sep 2, 2022

Hey thanks for this! For some reason, the audio doesn't work for me -- just gives me a clicking sound when I click the audio button. Could there be a problem with the init file?

Thank you! Works like a charm - same problem with the audio though!

I updated the fork. Hopefully it works now.

@Sabin-Pla
Copy link

Sabin-Pla commented Sep 15, 2022

@shoui520 The audio does not work for me. If I pull up the network traffic viewer when I click the audio button the init.py file does return a response which validates yomichan's required schema and the url provided in the response plays back just fine when I manually open it in the browser. The setup and your script seems fine but it still doesn't work :c

Edit: I think yomichan might be getting error 403/forbidden when trying to open the URLS. I've found a work around by downloading the mp3s using the same Session object we created in order to open the search page on fervo. We can then return the url (local path) of the mp3 to yomichan :)

@dansclearov
Copy link

@Sabin-Pla can you please share the changes you have done to the script to make it work?

@mautinobruno
Copy link

That's useful! Thanks!

@teksongeap
Copy link

absolutely amazing, this little tip has increased my quality of life exponentially, thanks dude

@shoui520
Copy link
Author

@shoui520 The audio does not work for me. If I pull up the network traffic viewer when I click the audio button the init.py file does return a response which validates yomichan's required schema and the url provided in the response plays back just fine when I manually open it in the browser. The setup and your script seems fine but it still doesn't work :c

Edit: I think yomichan might be getting error 403/forbidden when trying to open the URLS. I've found a work around by downloading the mp3s using the same Session object we created in order to open the search page on fervo. We can then return the url (local path) of the mp3 to yomichan :)

nice, i cant program but i hope someone can get the script working this way

@shoui520
Copy link
Author

I know I'm probably really late to this, but the Yomichan Forvo add-on got an update that just lets you change the language. Ive updated this guide.

@Wyzmic
Copy link

Wyzmic commented Oct 3, 2023

Could you make a traditional chinese to japanese dictionary? Doesn't seem to exist unfortunately

@roger-yu-ds
Copy link

roger-yu-ds commented Nov 7, 2023

The extraction from Forvo is not reliable, I have the settings for Mandarin, but sometimes the Japanese pronunciation is saved into Anki.

My Yomichan Forvo Server config is

{
    "language": "zh",
    "port": 8770,
    "preferred_usernames": [],
    "show_gender": true
}

and the Yomichan browser add-on setting for Audio Sources is

http://localhost:8770/?term={term}&reading={reading}&language=zh

On the Yomichan pop up, the Audio that play is in the correct language. But somehow the Japanese one is saved into Anki.

Any ideas on how to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment