# \[Userscript\] Forum and some websites: Prioritize Japanese glyphs (Han unification)

**URL:** <https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303>\
**Category:** API And Third-Party Apps\
**Created:** [January 18, 2022, 4:05pm UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303 "2022-01-18T16:05:12Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![polv](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/polv/32/572691_2.png) [@polv](https://community.wanikani.com/u/polv)\
**Post date:** [January 18, 2022, 4:05pm UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/1 "2022-01-18T16:05:12Z")

</div>

As of now, I don’t really frequent this forum, but I came across the fact that [Han unification](https://community.wanikani.com/t/font-differences-that-confuse-or-surprise-you/56634) also affects this forum. That is, some Kanji look different from what are usually seen in Japanese media. Instead, they became like of mainland China or Taiwan counterparts.

Some of the drastic differences include, 直線、海、過ぎる、似る、角、誤解.

After all, I don’t even know if it is even possible to force Japanese font (like Noto Sans JP) on Discourse, but I think it does matter, being a Japanese community.

For a global fix, is to [change the forum display language to Japanese](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/17), or to [use my UserScript](https://community.wanikani.com/t/should-this-forum-discourse-enforce-japanese-font/55303/13).

#### WaniKani Community-only version

> **[WaniKani Community prioritize Japanese glyphs](https://greasyfork.org/en/scripts/439780-wanikani-community-prioritize-japanese-glyphs)**
>
> Prioritization of Japanese glyphs for Han unification

#### Another version that add more websites.

> **[Lang attribute setter (prioritize Kanji font on Japanese Websites)](https://greasyfork.org/en/scripts/443575-lang-attribute-setter-prioritize-kanji-font-on-japanese-websites)**
>
> Fixes Han unification, for example, for Japanese (can be edited to prioritize other langs)

---

<div class="post-metadata">

**Author:** ![MegaZeroX](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/megazerox/32/461235_2.png) [@MegaZeroX](https://community.wanikani.com/u/MegaZeroX)\
**Post date:** [January 18, 2022, 4:20pm UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/2 "2022-01-18T16:20:07Z")

</div>

Ideally it should using var selectors, but I don’t know if it is feasible with the current tools, and if not, whether Discourse would add the feature for clients that use Eastern languages.

---

<div class="post-metadata">

**Author:** ![seanblue](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/seanblue/32/579844_2.png) [@seanblue](https://community.wanikani.com/u/seanblue)\
**Post date:** [January 18, 2022, 5:24pm UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/3 "2022-01-18T17:24:25Z")

</div>

If your device is set up to prioritize Japanese over Chinese (e.g. by installing a Japanese keyboard) it should always render correctly.

In HTML, you can specify the language per span/div, but I don’t think it would be straightforward to do that in Discourse. It would probably require overriding a lot of Discourse code since I’d guess they are generally language agnostic.

---

<div class="post-metadata">

**Author:** ![WillC](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/willc/32/488371_2.png) [@WillC](https://community.wanikani.com/u/WillC)\
**Post date:** [January 18, 2022, 6:10pm UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/4 "2022-01-18T18:10:51Z")

</div>

It should be possible to set `font-family` (CSS property) to a list including a Japanese font face / variant, although tbh I would find that annoying as despite having the Noto fonts installed, I would much prefer to use Motoya “Maru”.

---

<div class="post-metadata">

**Author:** ![hallowtime](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/hallowtime/32/836337_2.png) [@hallowtime](https://community.wanikani.com/u/hallowtime)\
**Post date:** [January 18, 2022, 10:04pm UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/5 "2022-01-18T22:04:36Z")

</div>

I don’t know  
but I would like to have the typefont changed  
preferably to Comic Sans MS

---

<div class="post-metadata">

**Author:** ![rfindley](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/rfindley/32/35202_2.png) [@rfindley](https://community.wanikani.com/u/rfindley)\
**Post date:** [January 19, 2022, 1:54am UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/6 "2022-01-19T01:54:50Z")

</div>

The only way to default to Japanese is to mark the whole forum as Japanese. But most of the forum is English, not Japanese. It would probably render everything better, but search engines might treat the forums differently if all the English text is marked as Japanese.

The _right_ way to do it is to mark Japanese text as Japanese, like this:

Japanese:  
` <span lang="ja">直線、海、過ぎる、似る、角</span>`  
Result: 直線、海、過ぎる、似る、角

Chinese:  
` <span lang="zh">直線、海、過ぎる、似る、角</span>`  
Result: 直線、海、過ぎる、似る、角

That’s not exactly intuitive, so it would be great to have a button or something to mark text as Japanese. But since WK’s forums are hosted by Discourse, customization probably isn’t an option.

---

<div class="post-metadata">

**Author:** ![WhimsyWorlds](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/whimsyworlds/32/669007_2.png) [@WhimsyWorlds](https://community.wanikani.com/u/WhimsyWorlds)\
**Post date:** [January 19, 2022, 1:56am UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/7 "2022-01-19T01:56:34Z")

</div>

Everywhere I go…  
I see him 😔  
 ![SansOverworldSprite](https://global.discourse-cdn.com/wanikanicommunity/original/4X/4/9/a/49affd3a82b50ba792e2ec2afebedbc2770a6dca.png)

---

<div class="post-metadata">

**Author:** ![MichaelCharles](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/michaelcharles/32/827818_2.png) [@MichaelCharles](https://community.wanikani.com/u/MichaelCharles)\
**Post date:** [January 19, 2022, 2:32am UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/8 "2022-01-19T02:32:26Z")

</div>

This script should attempt to import and use Noto Sans JP as a font, and then if not fallback on a variety of standard Japanese fonts.

```auto
// ==UserScript==
// @name Japanese Fonts for Wanikani Forums
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Try to import and use Noto Sans JP, and if not fall back on a standard Japanese font.
// @author Michael Charles Aubrey
// @match https://community.wanikani.com/*
// @icon https://www.google.com/s2/favicons?domain=wanikani.com
// @grant none
// ==/UserScript==

(function() {
    'use strict';

const style = document.createElement("style");
style.innerText = `
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP&display=swap');
* {
    font-family: "Noto Sans JP", "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", Osaka, メイリオ, Meiryo, "ＭＳ Ｐゴシック", "MS PGothic", "ＭＳ ゴシック" , "MS Gothic", "Noto Sans CJK JP", TakaoPGothic, sans-serif;
}
code * {
    font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace !important;
}
`

const head = document.getElementsByTagName("head")[0];
head.appendChild(style);
})();

```

---

<div class="post-metadata">

**Author:** ![ctmf](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/ctmf/32/183394_2.png) [@ctmf](https://community.wanikani.com/u/ctmf)\
**Post date:** [January 19, 2022, 2:49am UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/9 "2022-01-19T02:49:51Z")

</div>

> [@rfindley](#):
>
> Result: 直線

So THAT’S why my mac’s (chinese) handwriting input _stubbornly will not recognize_ when I draw 直 no matter how carefully I do it. Mystery solved.

---

<div class="post-metadata">

**Author:** ![polv](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/polv/32/572691_2.png) [@polv](https://community.wanikani.com/u/polv)\
**Post date:** [February 9, 2022, 3:38pm UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/10 "2022-02-09T15:38:15Z")

</div>

`<span lang="ja">` 直線、海、過ぎる、似る、角`</span>` doesn’t work for me.

It has to be

`<span lang="ja-JP">` 直線、海、過ぎる、似る、角`</span>`.

(I have just noticed I don’t really need `JP` after `ja-` in my browser, but hyphen is needed…)

> [@MichaelCharles](#):
>
> This script

There might be another UserScript solution to inject `lang="ja-JP"` as well.

---

<div class="post-metadata">

**Author:** ![rfindley](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/rfindley/32/35202_2.png) [@rfindley](https://community.wanikani.com/u/rfindley)\
**Post date:** [February 9, 2022, 3:44pm UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/11 "2022-02-09T15:44:46Z")

</div>

> [@polv](#):
>
> I have just noticed I don’t really need `JP` after `ja-` in my browser, but hyphen is needed

What browser are you using that requires a hyphen?? Whatever the case, it’s non-compliant.

---

<div class="post-metadata">

**Author:** ![polv](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/polv/32/572691_2.png) [@polv](https://community.wanikani.com/u/polv)\
**Post date:** [February 9, 2022, 3:47pm UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/12 "2022-02-09T15:47:18Z")

</div>

Firefox on Arch Linux. But yeah, it appears to be fine in Firefox on Android.

**EDIT:** much easier option is just, don’t use ttf-droid (`pacman -R ttf-droid`).

---

<div class="post-metadata">

**Author:** ![polv](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/polv/32/572691_2.png) [@polv](https://community.wanikani.com/u/polv)\
**Post date:** [February 9, 2022, 4:21pm UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/13 "2022-02-09T16:21:02Z")

</div>

> ⚠ This is a third-party script/app and is not created by the WaniKani team. By using this, you understand that it can stop working at any time or be discontinued indefinitely.

It appears that forcing font can be quite overdone and unbeautiful. (Also, an ugly way to avoid styling `code` using `!important`.)

Anyway, my UserScript is born. Get it here - [Wanikani Community Prioritize Japanese Glyphs](https://community.wanikani.com/t/userscript-forum-prioritize-japanese-glyphs-han-unification/55303#wanikani-community-only-version-1).

```auto
// ==UserScript==
// @name WaniKani Community prioritize Japanese glyphs
// @namespace https://github.com/patarapolw
// @version 0.1.3
// @description Prioritization of Japanese glyphs for Han unification
// @author polv
// @license MIT
// @match https://community.wanikani.com/*
// @icon https://www.google.com/s2/favicons?domain=community.wanikani.com
// @grant none
// ==/UserScript==

(() => {
  function injectLangHTML(lang) {
    // I might not need to use MutationObserver at all...
    const obs = new MutationObserver(() => {
      if (document.documentElement.lang !== lang) {
        document.documentElement.lang = lang;
      }
    });
    obs.observe(document.documentElement, { attributeFilter: ["lang"] });

    // Only this part is the real thing.
    document.documentElement.lang = lang;
  }

  injectLangHTML("ja-JP");
})();

```

* * *

**Edit:** It appears to be extremely simple. Only `<html lang="en">` needs to be edited. (And `<html lang="ja">` doesn’t work in Firefox for Arch Linux for some reasons.)

---

<div class="post-metadata">

**Author:** ![sirati97](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/sirati97/32/231114_2.png) [@sirati97](https://community.wanikani.com/u/sirati97)\
**Post date:** [February 9, 2022, 6:17pm UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/14 "2022-02-09T18:17:39Z")

</div>

interestingly installing the userscript did not change it at all for me. I guess its because I have japanese installed as a langauge with higher priority than chinese on my computer (i quite often experience the problem in the other direction tho)

---

<div class="post-metadata">

**Author:** ![sirati97](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/sirati97/32/231114_2.png) [@sirati97](https://community.wanikani.com/u/sirati97)\
**Post date:** [February 9, 2022, 6:20pm UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/15 "2022-02-09T18:20:39Z")

</div>

wait how are you using the discourse editor to enforce the language tag??

---

<div class="post-metadata">

**Author:** ![rfindley](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/rfindley/32/35202_2.png) [@rfindley](https://community.wanikani.com/u/rfindley)\
**Post date:** [February 9, 2022, 6:37pm UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/16 "2022-02-09T18:37:40Z")

</div>

Just type the span tags exactly as shown. Certain html tags and attributes are whitelisted in discourse. In fact, it was me and @seanblue that got the folks at discourse to whitelist the lang tag.

---

<div class="post-metadata">

**Author:** ![polv](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/polv/32/572691_2.png) [@polv](https://community.wanikani.com/u/polv)\
**Post date:** [March 9, 2022, 6:11am UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/17 "2022-03-09T06:11:49Z")

</div>

> [@rfindley](#):
>
> The only way to default to Japanese is to mark the whole forum as Japanese.

~~Actually, It’s not fixed even if the forum language is set to Japanese.~~

 ![image](https://global.discourse-cdn.com/wanikanicommunity/original/4X/2/8/d/28d1d69c422e91659df0ac492b557d57a789515b.png)

> [@polv](#):
>
> > [@rfindley](#):
> >
> > What browser are you using that requires a hyphen?? Whatever the case, it’s non-compliant.
> 
> Firefox on Arch Linux. But yeah, it appears to be fine in Firefox on Android.

Even now, it is perfectly fine with Firefox on Android, but yes, the forum language just has to be set to Japanese.

I thought WaniKani Team isn’t interested in translating the forum, but somehow, most of the badges are translated.

[![badges](https://global.discourse-cdn.com/wanikanicommunity/original/4X/a/1/5/a1551fbcf7b8dcf1190ca9e3e5a6982604822dc6.png)](https://community.wanikani.com/u/polv/badges)

---

<div class="post-metadata">

**Author:** ![rfindley](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/rfindley/32/35202_2.png) [@rfindley](https://community.wanikani.com/u/rfindley)\
**Post date:** [March 9, 2022, 11:00am UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/18 "2022-03-09T11:00:05Z")

</div>

Interesting.  
By the way, when I mentioned marking the whole forum as Japanese, I meant adding a `lang` tag to a top-level html tag, rather than actually configuring your account language.

But hey, if it works…

---

<div class="post-metadata">

**Author:** ![seanblue](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/seanblue/32/579844_2.png) [@seanblue](https://community.wanikani.com/u/seanblue)\
**Post date:** [March 9, 2022, 12:02pm UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/19 "2022-03-09T12:02:53Z")

</div>

> [@polv](#):
>
> I thought WaniKani Team isn’t interested in translating the forum, but somehow, most of the badges are translated.

That’s because most of the badges are built into Discourse and Discourse includes a Japanese translation of the site. Notice that all the custom WaniKani badges (like the durtle ones) aren’t translated.

---

<div class="post-metadata">

**Author:** ![polv](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/polv/32/572691_2.png) [@polv](https://community.wanikani.com/u/polv)\
**Post date:** [March 10, 2022, 2:12pm UTC](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303/20 "2022-03-10T14:12:27Z")

</div>

Actually, it becomes Chinese form again in Gmail app on Android.

I guess only certain Webviews can be fixed, otherwise it depends (mostly broken, though).

[Next page](https://community.wanikani.com/t/userscript-forum-and-some-websites-prioritize-japanese-glyphs-han-unification/55303.md?page=2)
