Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Korean keyboard won't type korean syllables #1398

Closed
hanuz06 opened this issue Dec 25, 2021 · 12 comments
Closed

Korean keyboard won't type korean syllables #1398

hanuz06 opened this issue Dec 25, 2021 · 12 comments
Labels
⚡️ Enhancement New feature or request

Comments

@hanuz06
Copy link

hanuz06 commented Dec 25, 2021

Hi Francisco,

For example: it should be "워", but it always types as '우 ㅓ'. How can I fix the problem? Thank you in advance.

korean-keyboard

@ghost ghost assigned hodgef Dec 25, 2021
@hodgef
Copy link
Owner

hodgef commented Dec 27, 2021

Hello Andrey, in most language layouts we rely on unicode character composition, which I don't think is working here. However, I've recently moved towards candidate box suggestions / IME starting with the Chinese (Pinyin) keyboard.

keyNavCandidates2

I think the best way to address your concerns is to move the Korean layout to this kind of input method. To accomplish this, I would need a detailed list of key candidates, such as this one: https://github.com/simple-keyboard/simple-keyboard-layouts/blob/master/src/lib/layouts/chinese.ts#L24

I will keep this task open as I look further into this.

Regards,
Francisco Hodge

@stale
Copy link

stale bot commented Jan 1, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@hanuz06
Copy link
Author

hanuz06 commented Jan 1, 2022

Hi Francisco,

Thank you for your reply. It's cool that the project is alive. The Korean language uses the alphabet and words are made of syllables. Luckily, there are fewer syllable constructions than in Chinese. It looks like this site has all possible Korean syllables combinations: Korean-syllables. Hopefully, this helps. Thank you for your hard efforts.

@hodgef
Copy link
Owner

hodgef commented Jan 6, 2022

Thanks for the information, I will look into this soon

@hodgef hodgef transferred this issue from hodgef/react-simple-keyboard Jan 6, 2022
@hodgef hodgef added the ⚡️ Enhancement New feature or request label Jan 6, 2022
@hodgef hodgef added this to Acknowledged in ⚡️ Enhancements Jan 6, 2022
@stale
Copy link

stale bot commented Jan 12, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale Issue automatically marked as inactive label Jan 12, 2022
@hodgef hodgef removed the Stale Issue automatically marked as inactive label Jan 12, 2022
hodgef added a commit to simple-keyboard/simple-keyboard-layouts that referenced this issue Jan 16, 2022
@hodgef
Copy link
Owner

hodgef commented Jan 16, 2022

Hello Andrey,

I have pushed updates to simple-keyboard and simple-keyboard-layouts to support Korean CandidateBox.

To try it out, please upgrade to the following:

  • simple-keyboard@3.4.29
  • simple-keyboard-layouts@3.1.29

Demo: https://codesandbox.io/s/fragrant-dawn-1w9eh?file=/src/index.js

Here's the layout that was changed:
https://github.com/simple-keyboard/simple-keyboard-layouts/blob/master/src/lib/layouts/korean.ts

Note: There will probably be some issues, such as missing syllabes, redundant or wrong entries, among others. I cannot verify as I'm not a native Korean speaker, so I will rely on the community to modify the layout linked above and submit PRs as needed.

Regards,
Francisco Hodge

@hodgef hodgef closed this as completed Jan 16, 2022
@hodgef hodgef moved this from Acknowledged to Shipped in ⚡️ Enhancements Jan 16, 2022
@hodgef
Copy link
Owner

hodgef commented Jan 17, 2022

I have published the update to react-simple-keyboard@3.4.38.

You can get your React setup to work by following this example:
https://codesandbox.io/s/mutable-framework-0y51i?file=/src/index.js

Regards,
Francisco Hodge

@hanuz06
Copy link
Author

hanuz06 commented Jan 17, 2022

Thank you very much, Francisco.

@hanuz06
Copy link
Author

hanuz06 commented Feb 7, 2022

@hodgef
Hi Francisco,

I wonder if korean keyboard is in unicode? With korean keyboard it shows correct syllables but it's not recognized by code. I investigated and found that same words typed from keyboard and typed from virtual keyboard have different character code.

I think the problem is that currently words typed from virtual keyboard are considered as a sequence of letters like in English but korean syllables have separate code type. For example: In a word "신", ㅅ = U+3145, ㅣ= U+3163, ㄴ = U+3134, and 신=U+C2E0. In virtual keyboard may show syllables as U+3145/U+3163/U+3134 but it should be U+C2E0.

So I wonder if it's possible to assign unicode to each syllable? If necessary I can make a list with each syllable assigned to corresponding unicode code.

This character codes for a word from virtual keyboard(String length is 6 because it considers the word as a sequence of letters):

utf8-virtual

This character codes for a word from real keyboard(String length is 2 because it considers the as a sequence of syllables):

utf8-real

@hanuz06
Copy link
Author

hanuz06 commented Feb 7, 2022

Actually the syllable code can be reliably calculated if we know all letters composing that syllable. So when a user clicks on that small window to make a syllable, the program can generate a syllable unicode code.

https://en.wikipedia.org/wiki/Korean_language_and_computers#Hangul_in_Unicode

@hodgef
Copy link
Owner

hodgef commented Feb 7, 2022

Hello @hanuz06,

Once you select a CandidateBox item, the item is decomposed like this:

const normalizedCandidate = selectedCandidate.normalize("NFD");

This is helpful if you made a mistake, as it allows you to hit backspace and remove that last portion of the syllabe (triggering the CandidateBox) instead of deleting the whole syllabe and starting over.

You can try out the various normalize functions to see their effect:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize

In that page there's a box that you can use to run your code. Try entering this:

const name1 = '신';
const name2 = '신';

console.log(`${name1}, ${name2}`, name1.length, name2.length);
console.log(name1 === name2);
console.log(name1.length === name2.length);

const name1NFC = name1.normalize('NFC');
const name2NFC = name2.normalize('NFC');

console.log(`${name1NFC}, ${name2NFC}`, name1NFC.length, name2NFC.length);
console.log(name1NFC === name2NFC);
console.log(name1NFC.length === name2NFC.length);

Returns:

> "신, 신" 3 1
> false
> false
> "신, 신" 1 1
> true
> true

Regards,
Francisco Hodge

@hanuz06
Copy link
Author

hanuz06 commented Feb 7, 2022

Thank you very much Francisco. normalize('NFC') works for korean syllables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚡️ Enhancement New feature or request
Projects
Development

No branches or pull requests

2 participants