Tuesday, September 7, 2010

How to change the layout of matchbox-keyboard to another language

Unfortunately currently matchbox keyboard supports only on keyboard layout, this is written in README file of package.

Problem statement : We need to load English keyboard layout if the LANG environment variable is set to for example to en_US.UTF-8 and German keyboard layout if LANG is set to de_DE.UTF-8 .

Solution : That to do this we have to do some little coding in matchbox-keyboard.c file.

Change following code

  kb->selected_layout
      = (MBKeyboardLayout *)util_list_get_nth_data(kb->layouts, 0);

to
  char* lang = getenv("LANG");
  if (!strcmp(lang, "en_US.UTF-8")) {
    kb->selected_layout
      = (MBKeyboardLayout *)util_list_get_nth_data(kb->layouts, 1);
  } else {
    kb->selected_layout
      = (MBKeyboardLayout *)util_list_get_nth_data(kb->layouts, 0);
  }
Also edit the keyboard.xml file to contain English and German keyboard layouts in my case. Approximately with this format.



...



 
    
   ...
   

...
 

....

Sorry for not so detailed instructions ... time is killing ...

Adios !