Bobulate


Posts Tagged ‘localization’

Kanuri and Hausa Keyboards, part 2

Monday, April 26th, 2010

Thanks to the comments on my previous blog entry about Hausa and Kanuri keyboard layouts, I’ve looked into the topic a little more, adding yet more options for typing.

Dead keys: the keyboard may have “dead keys” for accents. A dead key does not print anything when pressed, but combines with whatever you type next. For instance, you could have a dead accent acute key that combines with a, so you hit dead-acute followed by a and get á. In Kubuntu 9.04 (which is the OS I have at hand during this trip, so some of the advice offered in comments previously doesn’t apply) dead-acute k combines to ḱ. But this does offer a possible solution: using dead-acute with b, d, k, r and e. These will produce the Hausa b, d and k with a hook and the Kanuri r with a line and upside-down e.

First, I had to find a key on my keyboard to define as dead-acute, since I don’t have one otherwise. I used the strange key squashed between enter and the arrow keys, keycode 94.

xmodmap -e "keycode 94 = dead_acute"

From then, I could immediately use the dead-acute key for combinations that are already defined in X, like á, é, ń and others. But it doesn’t help me type Hausa all that much.

Next stop, .Xcompose. This is a file I create in my home directory. Reading it in seems to require an X restart, so log out and log in after creating the file. You will note that it uses the new dead-acute key to create all of the Hausa and Kanuri and the Naira symbol out of existing keys. The Naira is already pre-defined as multi-N-equals, but that is equally hard to type.

So I put this into my .XCompose. It takes the current configuration and then adds the dead-acute key combinations just described. Of course this is no official keyboard layout, but it may help some people type Hausa at speed when no other keyboard is available.


# Import default rules from the system Compose file:
include "/usr/share/X11/locale/en_US.UTF-8/Compose"

# Hausa definitions
<dead_acute> <k> : "ƙ" U0199 # HAUSA k
<dead_acute> <K> : "Ƙ" U0198 # HAUSA K
<dead_acute> <b> : "ɓ" U0253 # HAUSA b
<dead_acute> <B> : "Ɓ" U0181 # HAUSA B
<dead_acute> <d> : "ɗ" U0257 # HAUSA d
<dead_acute> <D> : "Ɗ" U018A # HAUSA D
<dead_acute> <e> : "ə" schwa # KANURI e
<dead_acute> <E> : "Ə" SCHWA # KANURI E
<dead_acute> <r> : "ɍ" U024D # KANURI r
<dead_acute> <R> : "Ɍ" U024C # KANURI R
<dead_acute> <n> : "₦" U20a6 # NAIRA SIGN
<dead_acute> <N> : "₦" U20a6 # NAIRA SIGN

I think an advantage of a dead-key approach is that you don’t have to hold anything down and the symbols on the keyboard still resemble what you’re typing. Of course, getting a dead-acute key to stick across sessions is the next issue to deal with, or perhaps I should set up something like super instead (that can be done with the KDE keyboard layout tool) so that super-b is ɓ.

In any case, it goes to show that there’s many ways to do it — whatever it is. In the end the KDE UserBase Compose Key tutorial has been vaguely helpful, but mostly the links at the bottom of that page.

[[ One might wonder why I’m blogging this kind of thing, but that’s because I promised some people here in Kano that I would look some things up for them, and the most effective way to get the information back to them — and back to their students — is to bung it on the internet, so that searching for Nigerian keyboard layouts for Hausa turns this information up (as well as useful things like the OLPC layout). ]]

Hausa and Kanuri Keyboards

Monday, April 26th, 2010

To type Hausa and Kanuri letters like ə, Ɓ or ƙ you will need to modify your keyboard layout. A keyboard layout maps the buttons on the keyboard to symbols which are displayed — you do not have to look at the letters painted on the keyboard and the computer doesn’t know what’s painted there anyway. Let’s look at three (and a half) ways of putting these letters into your document.

KCharSelect: the application ‘kcharselect’ helps you pick characters from the entire range of Unicode characters — if there’s a letter for something, then kcharselect can help you find it. On my KUbuntu 9.04 installation it is not installed by default, so I used the package manager to add it first (I used sudo apt-get install kcharselect but the graphical manager can do it as well). If you like GNOME apps, it looks like ‘gucharmap’ is the one you want.

Once kcharselect is started it presents you with a page full of characters. You can click on any character to obtain information about it, or double click on it to add it to the little text box at the bottom of the window.

At the top of the window there is a search bar; type part of a description or character name and the displayed characters will be filtered. For instance, I typed in “Nigeria” and that slims the display down to the letters I’m interested in (no capital ƙ though?) as well as a Naira sign. Good!

After double-clicking the characters I am interested in into the text bar below, the “to clipboard” button puts them on the clipboard so I can paste them into the document I’m writing. Bit of a round-about way to do it and not fast when typing long documents, but it works.

Using xmodmap: Each key on the keyboard has a number. To find out which number, start the “xev” program from a terminal window (in KDE, start konsole; in GNOME, start gnome-terminal; then type xev). A small window with a box will appear. Move the mouse over the window. Notice that lots of output appears in the terminal from which you started xev.

Next, hit a key on your keyboard. You will see more output, which looks something like this:


KeyPress event, serial 30, synthetic NO, window 0x1600001,
root 0x13c, subw 0x1600002, time 21276913, (48,63), root:(53,895),
state 0x0, keycode 51 (keysym 0x1000259, schwa), same_screen YES,

The important number is the keycode (51 in this example). That is the number of the key you just pressed.

It is convenient to find four different keys on your system, one for ə, one for ƙ, one for ɓ and one for ɗ. On my keyboard, I used the keys [, ], \ and \ (I have two \ keys) which have keycodes 34, 35, 51 and 94.

The next step is knowing what the keyboard symbols are that you want for each key. The ə is called schwa, but the other Hausa letters don’t have a name in the standard X keysym table. I looked them up with kcharselect so I could use their Unicode names, and found the following:


Khook Ƙ 0198
khook ƙ 0199
Bhook Ɓ 0181
bhook ɓ 0253
Dhook Ɗ 018A
dhook ɗ 0257

The final step is to assign these keyboard symbols to the key codes, so that when you press the key the right symbol appears. I’m going to put ƙ on my [ key (key code 34, key symbols U0199 and U0198). To do this, use xmodmap. This utility can be used to remap your keyboard, and can also hopelessly mess the keyboard up until you logout — so be a little careful.


xmodmap -e "keycode 34 = U0199 U0198"

This maps keycode 34 to U0199 (ƙ) when pressed normally and to U0198 (Ƙ) when pressed together with shift — just like normal lowercase- and uppercase letters. The next three commands assign the other keys:


xmodmap -e "keycode 35 = U0253 U0181"
xmodmap -e "keycode 51 = U0257 U018A"
xmodmap -e "keycode 94 = schwa SCHWA"

After these four commands, when I run my finger across the top row of letters on my keyboard, it produces qwertyuiopƙɓɗ; the ə is a strange key sandwiched between enter and the arrow keys. But the result is that I can type Hausa and Kanuri in a sensible way.

xmodmap revisited: instead of picking separate keys for each Hausa letter, you could add them to the existing keys for b, k, d and e. For that, we’ll need to make sure there is a Mode_switch key set. I used the AltGr key on my keyboard, and found out that it had keycode 108. So I set it to be the mode switcher with


xmodmap -e "keycode 108 = Mode_switch"

Then I set up the b key (for instance) with the symbols for b, B, ɓ and Ɓ. These will appear when the key is pressed normally, when it is pressed with shift, pressed with AltGr and when pressed with shift and AltGr.


xmodmap -e "keysym b = b B U0253 U0181"

Using keyboard layouts: I have tried the Nigerian keyboard layout, Hausa variant, but there I couldn’t find the ƙ at all, so I think that layout is broken in some way. I selected it from KDE’s systemsettings / Language & Region module under keyboard, but it’s no success. I can type lots of strange characters, but not the ones I need in Hausa.