Gaia/System/Keyboard/Layout: Difference between revisions
(Created page with "Hello! This goal of this document is to allow people to add keyboard layout of their own language/script on the '''v1 Gaia Keyboard app'''. == Status of the Gaia Keyboard app...") |
(+ contact points) |
||
Line 49: | Line 49: | ||
* [https://github.com/mozilla-b2g/gaia/tree/master/apps/keyboard/js/imes/jspinyin JSPinyin] is a written for Simplified Chinese and works by tapping Pinyin symbols. | * [https://github.com/mozilla-b2g/gaia/tree/master/apps/keyboard/js/imes/jspinyin JSPinyin] is a written for Simplified Chinese and works by tapping Pinyin symbols. | ||
* As a demonstration, [http://chewing.csie.net/ Chewing], an C/C++ open-source Zhuyin IME for Traditional Chinese, was [https://bugzilla.mozilla.org/show_bug.cgi?id=845685 cross-complied with emscripten] and linked with Gaia keyboard. | * As a demonstration, [http://chewing.csie.net/ Chewing], an C/C++ open-source Zhuyin IME for Traditional Chinese, was [https://bugzilla.mozilla.org/show_bug.cgi?id=845685 cross-complied with emscripten] and linked with Gaia keyboard. | ||
== Discussion, Q&A, etc == | |||
Please come to [https://lists.mozilla.org/listinfo/dev-gaia dev-gaia] mailing list or the <code>#gaia</code> channel on irc.mozilla.org. <code>#mozilla-taiwan</code> is the de-facto Chinese-language channel for this topic. |
Revision as of 04:09, 20 May 2013
Hello! This goal of this document is to allow people to add keyboard layout of their own language/script on the v1 Gaia Keyboard app.
Status of the Gaia Keyboard app & system architecture
Current version
As of mid-2013, the built-in Gaia keyboard app is the only keyboard app available in Firefox OS. That means, if you would like to add your own keyboard layout, you would have to modify the app itself and push it to your unlocked developer phone.
Next version
We plan to introduce plug-able keyboard/IME architecture directly into the OS in the next version. See bug 816869 for detail. When the feature is released, the users should be able to buy or install their own keyboard app, and use the layouts of those 3rd-party keyboard apps in conjunction with the built-in ones.
How-tos
The section below assume that you have already know how to flash your own Gaia on the phone (i.e., make install-gaia
), or update the application.zip
of keyboard app for Firefox OS Simulator.
Add a simple layout in the Gaia keyboard app
A simple layout refers to, e.g., Qwerty layout for English, where the app simply outputs what the user taps directly (as opposed to having the keys handles in Asian IMEs).
- Modify layout.js to add your own layout here. You should be able to figure out the syntax by looking at definition of other layouts.
- Reference your keyboard layout by hard-code it's name here in the
enabledKeyboardNames
array. That would enable your layout no matter what you'd choose in the Settings app.
Obviously you would have to do something else in order to make your keyboard layout show up as a setting entry and toggle-able, but this document describes the minimum.
Add a layout what works with an Asian IME
Introduction
East Asian languages (Chinese, Japanese, and Korean) uses a fairly complex script that involves thousands of characters. As there is no way to put thousands of keys on a hardware keyboard nor a software keyboard, users would rely on a piece of indexing program called input method, or IME for short, to convert series of symbols into a selections of candidate characters.
How symbols should be converted and how "smart" the IME should be depend on the method chosed, implementation itself, and often NLP science, which is not the scope of this document. One thing to note is that it is highly recommended to put the database part into IndexedDB, in order to conserve the memory usage on a mobile device.
IM Engine interface in Gaia keyboard app
Assuming you have an IME library readily available for converting symbols into characters (IM Engine in our terminology), you would need to use the defined interface within Gaia Keyboard app, available to the library to receive symbols from the layout, and to output the characters. The current API is documented in the comment here. We invite implementations in order to further refine this API within Gaia.
Make your IM engine work with your layout
- Put a new layout in layout.js as the previous section described.
- Reference the IM engine with
imEngine
property. When your layout is enabled, the keyboard app would start loading the script located atkeyboard/js/imes/<imEngine>/<imEngine>.js
. - APIs to receive and send the keys/characters should be setup when the script is loaded and
init
'd. - When the user tap any key/symbols on the keyboard, it would get send to the IM engine. Do whatever you want in response to the user input.
Known implementations
- JSZhuyin is the first implementation of Gaia Keyboard Asian IM engine, for Zhuyin IME for Traditional Chinese. Blame the author if you think the current API su*ks.
- JSKanji is a prototype IM engine written for Japanese.
- JSPinyin is a written for Simplified Chinese and works by tapping Pinyin symbols.
- As a demonstration, Chewing, an C/C++ open-source Zhuyin IME for Traditional Chinese, was cross-complied with emscripten and linked with Gaia keyboard.
Discussion, Q&A, etc
Please come to dev-gaia mailing list or the #gaia
channel on irc.mozilla.org. #mozilla-taiwan
is the de-facto Chinese-language channel for this topic.