futo-org / android-keyboard

Offical FUTO Keyboard Issue Tracker and Source Mirror of https://gitlab.futo.org/keyboard/latinime
Other
555 stars 19 forks source link

[Feature Request] Korean Language Support #279

Open plumpdolphin opened 1 month ago

plumpdolphin commented 1 month ago

This is my petition for adding Hangul/Korean language support to the keyboard! 🇰🇷

I see essentially 3 levels that this could be implemented to as there are two common keyboard layouts and a secondary writing system, Hanja, which could be added as a nicety but is not necessary for daily use.

Stage 1

Standard keyboard layout for Korean typing maps 1:1 with the QWERTY layout and could be an excellent start to get going!

Stage 2

An additional common keyboard layout that would be good to have is the 10-key layout, which may be more difficult but is preferred by some. This layout is commonly referred to as the Chunjiin/천지인 keyboard for those who are interested.

Stage 3

The last possible stage of implementation, which I believe would prove most challenging is Hanja support. This would include typing out a syllable in Hangul/Korean writing and then have suggestions provided for all of the Hanja characters which match that syllable block.

I believe that is complicated enough to warrant it's own feature request once Hangul is implemented; I'm just mentioning it here to get the conversation started.


These are just my thoughts, and I'm happy to hear any other feedback, suggestions, or questions to get the ball rolling!

midirhee12 commented 1 month ago

Can we add Chinese to this as well? It seems like there's voice language models for both langauges. It's just a matter of adding the support to use it. I assume that this is blocked until a keyboard is implemented.

plumpdolphin commented 1 month ago

Can we add Chinese to this as well? It seems like there's voice language models for both langauges. It's just a matter of adding the support to use it. I assume that this is blocked until a keyboard is implemented.

I definitely think there should be a Chinese keyboard! It looks like there's already an open issue for Chinese language support which you could find here: https://github.com/futo-org/android-keyboard/issues/55. Since it's going to have it's own layout and potential challenges, I think it's probably best handled separately there.

Note, the voice input works separately of the keyboard functionality, so even though there isn't a layout to type out Korean or Chinese, speech-to-text should still be functional!

plumpdolphin commented 1 month ago

Alright, I have taken first steps to fork, compile, and add a quick test layout to see if multi-key composition works automatically (handled by the OS) or if it must be handled by the keyboard. My suspicions seem to be confirmed that multiple characters are not converted into the appropriate character by Android and instead must be handled by the keyboard.

An example for those unfamiliar with the Korean language and typing, the Korean script called Hangul is split into syllable blocks which contain multiple characters. Anywhere from 1 standalone character for text abbreviations up to the largest blocks being 4 characters: 1 consonant -> 1 vowel -> 2 consonants, and always in that order.

For this to work, when a vowel is added it must check the previously pressed character to see if it is a consonant, and if it is, the consonant must be stripped of the previous syllable block and combined with the vowel that was pressed. An example of this would be like this:

ㅋㅣㅇ -> 킹 (King) ㅋㅣㅇㅏ -> 키아 (Kia)

Where the ㅇ/ieung character is taken from the previous syllable block and combined with the following vowel.

Unless there is an existing system for this that I'm unaware of, I believe that makes this issue a much more challenging to implement and would require additional backend work in addition to a keyboard layout. If anyone else has ideas on how to resolve this, that'd be great, otherwise it's a bit out of my depth to continue.

Edit: After doing additional research on the topic, it seems it might be best to utilize the existing libhangul/ibus-hangul project as the IME if possible to avoid rewriting the logic from scratch.

plumpdolphin commented 1 month ago

Since the composition aspect is not functional, I will not make a pull request yet. However, I have created a QWERTY layout for the Korean language and added all of the appropriate metadata that I could find without a contribution guide. I tried to match the Samsung standard layout best I could, with a few issues I did not resolve (% and , not showing in moreKeys).

It's at least a decent starting point for anyone who'd like to try tackling the issue! https://github.com/plumpdolphin/android-keyboard/commit/dbcde6d1a923b3850fed59f3d2a011cfe2201082

midirhee12 commented 1 month ago

I can help if you need it for understanding the typical korean layout as well.

plumpdolphin commented 1 month ago

Here is an current sample of the keyboard layout with the current broken bits:

  1. On the ㄹ key, it is set to !text/keyspec_currency which should be ₩ for KRW.
  2. On the ㅎ key, the moreKeys should be a % character, but that does not appear.
  3. On the ㅜ key, the moreKeys should be a , comma, but that also does not appear.
  4. Intermittent crashing because I most certainly missed something in configuration

image