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

WIP Add Chinese keyboards #876

Open
wants to merge 32 commits into
base: v3-main
Choose a base branch
from
Open

Conversation

kevinlin18
Copy link
Contributor

Original discussion: #798

Support Chinese keyboards by integrate Rime Input Method Engine
Features:

  • UI translation: Chinese Traditional
  • Quick switch between Chinese/English keyboards, can specific dictionary (Canada/UK/US)
  • Split UI, Keyboard language list in management
  • Supported input methods(keyboard) list:
    • Bopomofo
    • Cangjie
    • Luna Pinyin
    • Terra Pinyin

TODO
support stroke keyboard https://github.com/rime/rime-stroke

Known issues
'rimePreedit' not reset when leave a keyboard

Library:
librime 1.7.3

kevinlin18 and others added 30 commits December 4, 2022 17:13
Disable AddToDictionaryKey in ascii mode
add DictionaryLanguageForRime Setting
remove empty Chinese dic
put all Chinese keyboard in same folder
this change will make Rime auto commit selected candidate
@kmcnaught
Copy link
Collaborator

@JuliusSweetland

I've asked a chinese friend to clarify some things for me, but in the meantime these are the existing issues I think are present:

  • "Clear" sometimes clears the RIME input (i.e. removes suggestions) without clearing the scratchpad. It needs to clear both
  • I don't think "Back Word" works
    • I need to ask for clarification on how it would be expected to work
  • When switching between Chinese and English or vice versa, the prediction still contains part of what was already typed leading to various strange behaviours. Something needs to change here but I've asked for clarification on what would be reasonable, for example:
    • auto-add a space when switching from chinese to english? Should it take the current top prediction, or clear the current input?
    • clear any un-used input when switching from english to chinese?
  • When switching from Chinese to english, sometimes the predictions bar misbehaves, with the wrong term highlighted due to the shift from 4 -> 6 suggestions giving a weird scaling bug. This might disappear if we are clearing suggestions when switching.

@JuliusSweetland
Copy link
Member

JuliusSweetland commented Jun 30, 2023 via email

@kmcnaught
Copy link
Collaborator

I've been reviewing how the language is set in the installer, which needed some minor changes. Note that the Languages enum has been slightly overloaded - there is a single Languages enum whose constants describe either UI Language (all the previous ones, plus ChineseTraditionalTaiwan, and/or Keyboard Langauge + input methods (all the previous ones, plus 10 new ones like ChineseSimplifiedBopomofo, ChineseTaiwanTraditionalLunaPinyin, ChineseTraditionalTerraPinyin. So we have one enum list, but some enum constants don't correspond to a UI language, and some enum constants don't correspond to a keyboard language. This logic is mainly handled by presenting two different list of values to the user depending on the context. It feels like something that should be split out if we ever add another language that has more than one input keyboard available - the language and the input method should be nested. In fact, this would also suit the Simplified keyboards which are currently handled by a different boolean flag.

I'm not proposing this refactoring is essential now, but flagging it as something that should be considered next time we poke the nest. And it's important context for the following remarks.

In the installer, we allow people to choose a language, and (until now) use it for both the UI language and keyboard language. This can be separated in the management console if people want them to be different. This doesn't work for chinese though, because the list of available Chinese UI languages and Chinese keyboard languages are disjoint.

We also have a bunch of preexisting logic which tries to be smart about defaulting to the local culture if possible (e.g. if Windows is in French, you have "French" preselected in the languages dropdown but can choose another).

What I've done, which I think is reasonable given the current constraints, is this:

  • in the installer, the user is given the list of keyboard languages to choose from, e.g. all the input methods like ChineseSimplifiedBopomofo, ChineseTaiwanTraditionalLunaPinyin, ChineseTraditionalTerraPinyin.
  • This is used as the default keyboard language for Optikey
  • If a "Chinese" option is chosen then the UI language is automatically set to ChineseTraditionalTaiwan which is the only translation we have available.
  • If the system language is "zh-CH" (China) or "zh-TW" (Taiwan) then the dropdown should default to one of the options that supports Simplified (for China) or Traditional (for Taiwan). I think this is an okay heuristic, I don't actually know which it will pick (probably the first or last in the list). I haven't tested this as changing my PC to Chinese is scary, but I don't think it's critical as it's just a nice-to-have hint. It would also be okay if it failed and the dropdown defaulted to English.

@kmcnaught
Copy link
Collaborator

General update - this is ready for testing.

To Do:

  • Need a translation for "English dictionary for Rime" which I think should just be "English dictionary" in the following screenshot
  • Need to work out what to do with Symbols keyboard (based on testing)

screenshot

@kmcnaught
Copy link
Collaborator

@JuliusSweetland this branch is now ready for testing both Chinese + touch input. You should be able to make an installer fine if required, or just share the bin directory for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants