Showing posts with label ibus. Show all posts
Showing posts with label ibus. Show all posts

Monday, February 7, 2011

Set default half punctuation in IBUS

I usually use half punctuation even when I am typing Chinese character. I should use full punctuations unless I need to type some formal and official documents. Every time, I launch IBUS which these two action "Ctrl+space" to turn on IBUS and then "Ctrl+." to switch to half punctuation mode.

Recently, I take a look of IBUS source code and I found how IBUS determine which mode is turned on by default. It look at the table database file. For me, I use cangjie3. Thus I edit the database with sqlite3 (you can use apt-get to install it)
$ sqlite3 /usr/share/ibus-table/tables/cangjie3.db

Then, you can view your current setting by:
select * from ime;

You can see that by default,def_full_width_punct is set to be TRUE. Thus, I simply set it to be FALSE using sql:
update ime set val='FALSE' where attr='def_half_width_punct';

Finally, you just need to restart IBUS and you will find the default punctuation mode is half.

Sunday, February 6, 2011

Set Default Traditional Chinese in IBUS under English Ubuntu 10.10

I am using Ubuntu 10.10 in my netbook. Basically, this is good and I used it for a long time. However, I hate the Ibus default setting for my usual chinese input method (cangjie) as the default chinese mode is simplied chinese if I use English Ubuntu (locale: LANG: en_HK). Thus, I found a way to solve my problem and set the default chinese mode to be traditional. I modified the ibus problem.

1. Edit /usr/share/ibus-table/engine/table.py
2. Find the following code (at about line 116)
if __lc.find('zh_') == 0:
                # this is a zh_XX
                __place =__lc.split('_')[1]
                if __place == 'cn':
                    return 0
                else:
                    return 1
            else:
                if self.db._is_chinese:                                                                               
                    # if IME declare as Chinese IME
                    return 0
                else:
                    return -1
3. Edit as following
if __lc.find('zh_') == 0:
                # this is a zh_XX
                __place =__lc.split('_')[1]
                if __place == 'cn':
                    return 0
                else:
                    return 1
            else:
                if self.db._is_chinese:                                                                               
                    # if IME declare as Chinese IME
                    # return 0
                    return 1  #Edit this line to return 1 instead of 0
                else:
                    return -1
4. Restart IBUS and DONE