For years now, we've been trying to get the furigana extension at Japanese.SE working here. Stack Exchange staff have informed us that they're not intending to implement this, which is unsurprising: the code is rather old now, and doing so would require some knowledge of both Chinese and Japanese.
However, we've been discussing this with Stack Exchange staff recently, and they seem happy to activate the code, provided we make/modify/test it ourselves. So, where do we begin doing that?
How can I test/edit the script at home?
The specific script is here. It can be run through the Tampermonkey browser extension after adding a header e.g.:
// ==UserScript==
// @name Furigana Test
// @include *chinese.meta.stackexchange.com*
// ==/UserScript==
In this way, we can modify the script locally.
So what happens if we do that?
If we type something like
- [卞]{biàn} [妆]{zhuāng} [阿尔巴尼亚]{Ā'ěrbāníyǎ} [三人行,必有我师焉]{Sān rénxíng, bì yǒu wǒ shī yān} 我叫[鑢壮壮]{Lǜ Zhuàngzhuàng}
- [八]{ㄅㄚ} [杷]{ㄆㄚˊ} [馬]{ㄇㄚˇ} [法]{ㄈㄚˇ} [地]{ㄉㄧˋ}
- [處]{cyu3}[處]{cyu3}[聞]{man4}[啼]{tai4}[鳥]{niu5} [處處聞啼鳥]{cyu3cyu3man4tai4niu5} [處]{cyu³}[處]{cyu³}[聞]{man⁴}[啼]{tai⁴}[鳥]{niu⁵} [處處聞啼鳥]{cyu³cyu³man⁴tai⁴niu⁵}
It comes out looking like:
And if we hover over 三人行,必有我师焉 with the mouse, it enlarges the text:
This is why I think it's incredibly close to working "as is". I'm fairly sure 95%+ of use cases here are putting pronunciation above a small selection of words, and this can be achieved "as is".
What goes wrong?
As the code states, it...
* makes sure Japanese text is displayed using a Japanese font to fix the issues in Google Chrome: https://japanese.meta.stackexchange.com/questions/1141
So the code changes Chinese fonts to Japanese fonts, e.g.
门 真
comes out looking like:
Deleting the relevant lines of code seems to get rid of this problem, specifically: 1. the whole
jaFonts
andmakeJaFonts
functions, 2. the line containingfont-family: ' + this.fontsToCSS(this.jaFonts)
, 3. the linethis.makeJaFonts(inElm);
. This seems to fix the problem:
There's code for "pitch accent", which we don't need. At the same time, it doesn't seem to interfere with anything.
I also encountered performance issues with a page full of pinyin, but that'll be the case at Japanese.SE too.
So...?
I'm hoping others will jump aboard and help test/modify this script. (I'm not familiar with IPA and pitch accent.)
It'd be great to know what parts of it work, and what parts we can delete. Implementing new features seems impossible, unless someone comes along with the relevant expertise.
Anyway, let's hear your feedback.