Unexpected-Keyboard icon indicating copy to clipboard operation
Unexpected-Keyboard copied to clipboard

Support for Japanese Language

Open kongreif opened this issue 1 year ago • 26 comments

There is no support for Japanese currently.

Japanese virtual keyboards on phones work the same way as unexpected keyboard. They utilise swipe actions to type different kana (syllable characters). image In the top middle you can see the か(ka) character. If you tap it, you type か(ka), if you swipe up for example you type く(ku), if you swipe down you type こ(ko) and so on. Therefore I think it would fit perfectly into the app.

One complexity is however that while typing Japanese kana, you need to get suggestions to convert them into Kanji (logographic characters). E.g. if you type かわいい it should suggest 可愛い to you. image

I'm not sure, how that works (e.g. if there's a general database of kana to kanji conversions that apps like Gboard utilise).

Is there a plan to add Japanese language support?

kongreif avatar Jun 10 '24 13:06 kongreif

The simple part can be achieved by writing a custom layout file; see the documentation.

That doesn't address suggestions/conversions, though.

Spike-from-NH avatar Jun 11 '24 09:06 Spike-from-NH

There is an open source dictionary from Mozc

ai25 avatar Jun 24 '24 11:06 ai25

@Spike-from-NH thanks for the info. This would need to happen on a per user basis though? Is there a way to contribute an additional layout for Japanese? @ai25 Thank you! There's also Anthy, which a lot of people use for Japanese language conversion on Linux.

I think this app could get a lot of traction, by adding Japanese language. There's no open source alternative. Most privacy conscious people use google keyboard without network functionality to be able to type in Japanese.

kongreif avatar Sep 01 '24 13:09 kongreif

@kongreif, it could be done with a custom layout. This doesn't mean every user of katakana has to devise one. I mention at the end of the document linked to above that ➊ this project has a repository for potentially useful layouts, and ➋ if you point to those other apps or show that your layout is pretty standard, @Julow may include it in future releases as one of the built-in layouts.

Spike-from-NH avatar Sep 01 '24 14:09 Spike-from-NH

@Spike-from-NH Oh thank you, I missed that! I will look into it.

kongreif avatar Sep 01 '24 17:09 kongreif

~~I'm not familiar with the law, but I'm concerned that this may violate the patent of flicking input (https://www.j-platpat.inpit.go.jp/c1801/PU/JP-2008-282380/11/en).~~ I think also Japanese character conversion and suggestion are too complex to be added to this app. I want JIS-based QWERTY layout will be added as Japanese user to input alphabets and symbols.

Edit: It seems that the patent requires input guiding, so swiping input in this app doesn't violate it. I'm sorry for misinformation.

cknight828 avatar Sep 02 '24 07:09 cknight828

@cknight828, I concur that translation/conversion/heuristics are outside the scope of a "lightweight" keyboard.

Spike-from-NH avatar Sep 02 '24 11:09 Spike-from-NH

I made かな入力(kana input) layout for hiragana and katakana. kana_jis_jp.txt (please convert to .xml) I need some help with ゛(dakuten) and ゜(handakuten). These symbols have to be combined with the preceding character when it is suitable, otherwise they should be treated as single character. For example if dakuten is inputed after か, the result have to be が, not か゛. But if dakuten after あ, the result should be あ゛(2 characters). How can I achive this?

cknight828 avatar Sep 03 '24 10:09 cknight828

@cknight828, what you want would have to be added to the Unexpected Keyboard code. This would improve the support for Japanese. One could implement dakuten and handakuten like the above-letter accents for European languages, though they are typed before, not after, the letter to be modified. Or the sequences could be added to the new Compose key, though you would then type Compose+か+゛.

All you can do with custom layouts is specify a key or a swipe for each combination. However, I think there are only 5+5 of them. This would be faster to type.

Spike-from-NH avatar Sep 03 '24 17:09 Spike-from-NH

I made かな入力(kana input) layout for hiragana and katakana. kana_jis_jp.txt (please convert to .xml) I need some help with ゛(dakuten) and ゜(handakuten). These symbols have to be combined with the preceding character when it is suitable, otherwise they should be treated as single character. For example if dakuten is inputed after か, the result have to be が, not か゛. But if dakuten after あ, the result should be あ゛(2 characters). How can I achive this?

This is not useful for native Japanese speakers without also adding an IME. Nobody wants a keyboard that can only type hiragana, and not katakana or kanji. And most Japanese speakers use romaji input or flick input anyway.

Like it has been established multiple times in this repo towards people requesting Chinese support, an IME is out of scope for a lightweight keyboard like Unexpected Keyboard. Your efforts are better spent on trying to implement custom keyboard layouts in Fcitx.

spiraldoll avatar Sep 05 '24 09:09 spiraldoll

This is not useful for native Japanese speakers without also adding an IME. Nobody wants a keyboard that can only type hiragana, and not katakana or kanji. And most Japanese speakers use romaji input or flick input anyway.

@spiraldoll I know. Should not the layout be included?

cknight828 avatar Sep 05 '24 11:09 cknight828

This is not useful for native Japanese speakers without also adding an IME. Nobody wants a keyboard that can only type hiragana, and not katakana or kanji. And most Japanese speakers use romaji input or flick input anyway.

@spiraldoll I know. Should not the layout be included?

It's not useful either. There's no demand for a Japanese keyboard that can't convert into kanji.

Even if there were, the behavior of Shift is incorrect.

spiraldoll avatar Sep 05 '24 11:09 spiraldoll

@spiraldoll Thank you for advice. I decided to separate it from the translation pr.

cknight828 avatar Sep 05 '24 13:09 cknight828

I need some help with ゛(dakuten) and ゜(handakuten). These symbols have to be combined with the preceding character when it is suitable, otherwise they should be treated as single character.

Combining characters are not out of the question but @spiraldoll is right that it must stay lightweight.

Combinations like this are usually done with "modifiers" in this app, meaning the modifier (the dakuten or handakuten) is typed first, then the combined character is typed. Would that work for you ? This works with tables that are defined like this: https://github.com/Julow/Unexpected-Keyboard/blob/master/srcs/compose/accent_aigu.json

These tables can be quite large without impacting the app size too much but I don't know if they are sufficient for kanji. A quick search seems to indicate that the 2000 most common kanjis could be enough? The keyboard could reasonably support that.

Julow avatar Sep 08 '24 14:09 Julow

I used this compose sequence for dakuten and handakuten: https://github.com/cknight828/Unexpected-Keyboard/blob/dakuon/srcs/compose/compose/dakuon.json

I removed kana input because it is very tight in portrait mode and kana input method itself is rarely used. (only 10% of people use it.) To be honest, I didn't use it so much.

There are some methods of inputting kanji with key combinations, but they are used only by professionals of data inputting. They are too complex to remember for ordinary people. And some of conversion tables are not publicly avaialble. I found an example of kanji input: https://packages.debian.org/bookworm/t-code , but I don't know how to use it.

cknight828 avatar Sep 08 '24 15:09 cknight828

I've added dakuten and handakuten as more usual diacritics and added your layout in this branch: https://github.com/Julow/Unexpected-Keyboard/tree/dakuon Can you try it ? Feel free to continue working on top of this branch and to open a PR from it.

Julow avatar Sep 10 '24 19:09 Julow

Can they be inputted like hangul? Dakuten and handakuten should be inputted after kana. It is better they also can be inputted as separate character. They are sometimes used in slang, such as え゛/ん゛.

cknight828 avatar Sep 13 '24 09:09 cknight828

Why are you still talking about this?! Japanese support is impossible on Unexpected Keyboard and it’s a waste of time talking about it instead of campaigning Fcitx to allow layouts other than QWERTY.

spiraldoll avatar Sep 13 '24 09:09 spiraldoll

@spiraldoll What is problem? Or what do you want? Closing this issue or adding Japanese support to Fcitx, or something else?

cknight828 avatar Sep 13 '24 10:09 cknight828

@cknight828, the feature will not be useful to Japanese, who want to opt for full kanji at will. That does not mean it's not useful to anyone. People typing roman-ji may benefit from having easy access to a katakana layout, as I'm told katakana is mostly used to sound out words from Western languages.

@spiraldoll, yes, it would be better to type these characters after the main character. However, I think it will be a conceptual problem to implement some of the "accent" keys after and some before. Your post may argue for making both of them separate keys that can be joined using the Compose key (or not joined at all).

Spike-from-NH avatar Sep 13 '24 19:09 Spike-from-NH

People typing roman-ji may benefit from having easy access to a katakana layout, as I'm told katakana is mostly used to sound out words from Western languages.

People, don't believe the words of a novice who can't even spell "romaji" correctly.

This thread is a waste of time and should be closed as not planned.

We have ample precedent that Unexpected Keyboard will not support Chinese input, which similarly requires an IME. There is no reason in the world why Japanese should be any different.

spiraldoll avatar Sep 13 '24 23:09 spiraldoll

@Spike-from-NH You mentioned me and spiraldoll incorrectly, don't you? I understand the latter part.

@spiraldoll あえて日本語で書きますが、確かに漢字が入力できなければ日常的な入力には対応できない事、漢字入力の追加は厳しい事には同意します。 しかし私が開発を続けている理由は、個人的にこのキーボードを使用する場面があるからです。 例えばTermuxでは、記号の入力の容易さや、Esc・Ctrl+C(SIGINT)などを入力する必要性から使用しています。 その中で、例えばコメントを書く時はひらがな、カタカナだけで十分です。 またC:DDAというゲームはAndroid版がありますが、記号類、Esc、Backtab、F3などの特殊キーを多用するので、このキーボードやHacker's Keyboardなどではないと快適にプレイできないのです。それでいて、アイテムの検索などには日本語が必要となりますが、かなが入力できればある程度は対応できます。漢字が必要な時にはキーボードを変更しなければいけませんが、それは他のキーボードでも英語、日本語を切り替える事になるので問題とは思いません。

現時点ではひらがな・カタカナの入力にIMEを使用していません。 濁点、半濁点の合成が改善されれば、指摘のあったShiftキーの挙動の問題が解消できます。 また、かな入力はデフォルトでオフなので、存在が問題になるとは思いません。

( I use Japanese here. I agree that it is insufficient for everyday use without kanji and support kanji inputting is difficult. But I work on this keyboard because I use it. For example, I prefer this keyboard in Termux for easiness of inputting symbols and need of Esc or Ctrl+C(SIGINT). Kana is sufficient for comment in this. And I play C:DDA, which is a game with Android version, and I can play it smoothly only with this keyboard or Hacker's Keyboard because it needs many use of symbols, Esc, Backtab, F3, and so on. It still needs Japanese for searching items, but I can do partially with kana. I have to change to other keyboards when kanji is needed, but I don't think this is a problem because I also have to change from English mode to Japanese mode when using other keyboards.

The IME is not currently used for kana. The problem of shift key behaivor you mentioned will be solved with improving dakuten and handakuten input. I don't think kana input layout causes problem because it is off in default.)

cknight828 avatar Sep 14 '24 03:09 cknight828

@cknight828 If you want to use Unexpected Keyboard with a use case that only you and probably 2 other people in the world tops actually has, do it in your own time. Don’t waste everyone else’s time giving them the impression that this is actually beneficial to Japanese speakers except you.

Here’s a layout I just thought up and have no plans of using myself:

<keyboard name="Flick (Japanese)" lang="ja">
  <modmap>
    <shift a="あ" b="あ゙"/>
    <shift a="い" b="い゙"/>
    <shift a="う" b="ゔ"/>
    <shift a="え" b="え゙"/>
    <shift a="お" b="お゙"/>
    <shift a="か" b="が"/>
    <shift a="き" b="ぎ"/>
    <shift a="く" b="ぐ"/>
    <shift a="け" b="げ"/>
    <shift a="こ" b="ご"/>
    <shift a="さ" b="ざ"/>
    <shift a="し" b="じ"/>
    <shift a="す" b="ず"/>
    <shift a="せ" b="ぜ"/>
    <shift a="そ" b="ぞ"/>
    <shift a="た" b="だ"/>
    <shift a="ち" b="ぢ"/>
    <shift a="つ" b="づ"/>
    <shift a="て" b="で"/>
    <shift a="と" b="ど"/>
    <shift a="な" b="ぱ"/>
    <shift a="に" b="ぴ"/>
    <shift a="ぬ" b="ぷ"/>
    <shift a="ね" b="ぺ"/>
    <shift a="の" b="ぽ"/>
    <shift a="は" b="ば"/>
    <shift a="ひ" b="び"/>
    <shift a="ふ" b="ぶ"/>
    <shift a="へ" b="べ"/>
    <shift a="ほ" b="ぼ"/>
    <fn a="あ" b="ぁ" />    
    <fn a="い" b="ぃ" />    
    <fn a="う" b="ぅ" />    
    <fn a="え" b="ぇ" />    
    <fn a="お" b="ぉ" />
    <fn a="つ" b="っ" />    
    <fn a="や" b="ゃ" />    
    <fn a="ゆ" b="ゅ" />    
    <fn a="よ" b="ょ" />    
    <fn a="わ" b="ゎ" />
    <fn a="か" b="ヵ" />
    <fn a="け" b="ヶ" />
    <fn a="ま" b="々" />                
  </modmap>
  <row>
    <key key0="config"/>
    <key key0="あ" key5="い" key6="え" key7="う" key8="お"/>
    <key key0="か" key5="き" key6="け" key7="く" key8="こ"/>
    <key key0="さ" key5="し" key6="せ" key7="す" key8="そ"/>
    <key key0="backspace" key8="delete"/>
  </row>
  <row>
    <key key0="left"/>
    <key key0="た" key5="ち" key6="て" key7="つ" key8="と"/>
    <key key0="な" key5="に" key6="ね" key7="ぬ" key8="の"/>
    <key key0="は" key5="ひ" key6="へ" key7="ふ" key8="ほ"/>
    <key key0="right"/>
  </row>
  <row>
    <key key0="shift"/>
    <key key0="ま" key5="み" key6="め" key7="む" key8="も"/>
    <key key0="や" key5="・" key6="ー" key7="ゆ" key8="よ"/>
    <key key0="ら" key5="り" key6="れ" key7="る" key8="ろ"/>
    <key key0="space"/>
  </row>
  <row>
    <key key0="fn"/>
    <key key0="、" key5="(" key6=")" key7="「" key8="」"/>
    <key key0="わ" key5="ゐ" key6="ゑ" key7="fn" key8="を"/>
    <key key0="。" key5="\@" key6="\#" key7="?" key8="!"/>
    <key key0="enter"/>
  </row>
</keyboard>

spiraldoll avatar Sep 14 '24 12:09 spiraldoll

I will wait whether Julow closes this issue.

cknight828 avatar Sep 14 '24 13:09 cknight828

Sorry for my lack of response, I was not commenting as I'm not competent on the subject.

If adding Japanese support requires a large dictionnary, then this is not possible right now without a large amount of work. This is the same foundation work that is needed for https://github.com/Julow/Unexpected-Keyboard/issues/343

I don't mind including the layout that is being discussed here in the app, even if it doesn't have a lot of users. Though I don't want to deceive others by giving the impression that the app can type like a other more advanced keyboard. This layout should not be the default for Japanese and it should be clear on what it does in its name.

This is not possible at the moment but should be easy to add if the dictionnaries are not too large. I have a work in progress in this branch: https://github.com/Julow/Unexpected-Keyboard/compare/master...korean-normalisation

I would not close this issue as long as @cknight828 thinks this is useful. Please continue experimenting :)

Julow avatar Sep 14 '24 21:09 Julow

@Julow Thank you, but I quit working on it. I realized I was just persisting on adding it. It is possible to be used, but not a suitable way in the normal situation. Sorry. It works standalone anyway, so I open pr in the layout repository. If someone wants to add Japanese layout, I'm glad to help.

cknight828 avatar Sep 14 '24 23:09 cknight828

@spiraldoll Great! I reckon this layout without Kanji support is still useful. Will this layout be submitted to https://github.com/Julow/Unexpected-Keyboard-layouts?

siumk avatar Feb 01 '25 12:02 siumk