[RELEASE] Chinese keyboard addon module
#1
I make this addon module to support input Chinese in xbmc. python developers can import this addon to input Chinese. and I think the better way is change the internal keyboard to addon, so we can select custom keyboard addon to support input any language we want.

Source code manage in project xbmc-addons-chinese.

Download version here
script.module.keyboard.chinese-2.0.2.zip

And install "script.module.keyboard.chinese-xxx.zip" from XBMC Addons Manager and select "Install from zip file"

This module use Baidu Online Pinyin IME (http://olime.baidu.com/) to input Chinese words.

Usage:
1. Add required import in your addon.xml
Code:
<requires>
    . . .
    <import addon="script.module.keyboard.chinese" version="1.0.0"/>
</requires>

2. Normal Use ChineseKeyboard
Code:
import ChineseKeyboard
default=''
heading='中文输入法'
keyboard = ChineseKeyboard.Keyboard(default,heading)
keyboard.doModal()
if (keyboard.isConfirmed()):
    input_string = keyboard.getText()

screen shot for xbmc 13:
[attachment=335]

screen shot for kodi 14:
[attachment=336]
Reply
#2
thank you very much
Reply
#3
Question 
Hi Taxigps,

First of all, thanks the great contribution to XBMC and the Chinese community, with the wonderful Chinese add-ons. I enjoy them a lot on my ATV.

I had problem when I directly replace the xbmc.Keyboard with ChineseKeyboard. It seems the xbmc built-in keyboard is able to doModal before xbmc launches the directory-scanning, but the python add-on keyboard runs after xbmc fires up the directory scan, and thus the directory-scan window covers up the keyboard window.

I referred the SoMovie code, and came up below work around. It end the directory scan first, run the keyboard and get input, then re-launch the container with the input keys as new parameter.

It works ok, but there is a user noticeable behavior difference. Searching with xbmc keyboard doesn't leave the current folder, thus it stays in the folder if user cancels keyboard input. With the workaround, searching opens a new empty folder, and when user cancels input, he has to click the '..' button to return to the search page.

I'm wondering whether there is a better solution.

Code:
...
    # Add 'Search' button, as it needs to parse the search result then
    # generate new buttons.
    addDir('Search', '', 'search()', isfolder=True)
...

def searchDefaultKeyboard(key=None, mode='all'):
    if not key:
        keyb = xbmc.Keyboard('', 'Search')
        #keyb = ChineseKeyboard.Keyboard('', 'Search')
        keyb.doModal()
        if keyb.isConfirmed():
            key = keyb.getText()
    if not key:
        return
    url = 'http://sou.kuwo.cn/ws/NSearch?key='+urllib.quote_plus(key)+'&type='+mode
    params['url'] = url
    processWebPage(hSearchResult)


def searchChineseKeyboard(key=None, mode='all'):
    if key:
        print('search input: %s' % key)
        url = 'http://sou.kuwo.cn/ws/NSearch?key='+urllib.quote_plus(key)+'&type='+mode
        print('search url: %s' % url)
        params['url'] = url
        processWebPage(hSearchResult)
    else:
        # Somehow, current chinese keyboard implementation works differently than the default keyboard.
        # The doModal doesn't prevent xbmcplugin from popping up the directory-scanning window, which
        # covers up the keyboard window.
        # A workaround is to terminate the directory, doModal, pass in keyboard input as new param of
        # the container, then relaunch the container.
        xbmcplugin.endOfDirectory(int(sys.argv[1]))
        keyboard = ChineseKeyboard.Keyboard('', 'Search')
        keyboard.doModal()
        if (keyboard.isConfirmed()):
            keyword = keyboard.getText()
            if not keyword:
                return
            u=sys.argv[0]+"?url="+urllib.quote_plus('')+"&mode="+urllib.quote_plus('search("'+keyword+'")')
            xbmc.executebuiltin('Container.Update(%s,replace)' % u)

# Choose ChineseKeyboard if script.module.keyboard.chinese is installed.
try:
    import ChineseKeyboard
    search = searchChineseKeyboard
except:
    search = searchDefaultKeyboard
Reply
#4
Wink 
If you are still using xmbc Dharma release, you may use the method described in the following link i.e. set zorder=1:

http://code.google.com/p/xbmc-addons-chi...tail?id=10

For xbmc Eden release, the fix is not working as explained in:
http://code.google.com/p/xbmc-addons-chi...tail?id=13
Reply
#5
Support Eden now.
Reply
#6
could anyone tell me where is that addon.xml i should add that "requires"? I found there is addon.xml under each sub-folder under XBMC/addons/.

and where should i put second part codes?

thanks for any help
Reply
#7
after installed from zip file and nothing happen, and cant find it in the xmbc add on folder, guess its not installed, i have mac eden, it only work for windows?
Reply
#8
(2012-10-20, 19:18)agamjl Wrote: after installed from zip file and nothing happen, and cant find it in the xmbc add on folder, guess its not installed, i have mac eden, it only work for windows?

This is a addon module, use by addon developer. will called by other addon need chinese input. Not show in list after install.
Reply
#9
Actually, Baidu online IME has failed.
the domain olime.baidu.com shows an internal error, like Baidu abandons maintaining it anymore or it seems so

Please, could you find an alternative online IME?

There're many out there.

http://pinyin.sogou.com/cloud/

http://py.qq.com/web/

Thanks
Reply
#10
(2012-12-15, 03:46)moto_v70 Wrote: Actually, Baidu online IME has failed.
the domain olime.baidu.com shows an internal error, like Baidu abandons maintaining it anymore or it seems so

Please, could you find an alternative online IME?

There're many out there.

http://pinyin.sogou.com/cloud/

http://py.qq.com/web/

Thanks

Baidu changed API. Upgrade addon to 1.2.7 to fix this.
Reply
#11
Bug:
Wordsperpage not used correctly. When final get the word user choosed, should *(wordperpage +1)
Reply
#12
Any chance to let this wonderful add on work on V13? Thank you!
Reply
#13
(2012-12-27, 13:54)ulion Wrote: Bug:
Wordsperpage not used correctly. When final get the word user choosed, should *(wordperpage +1)

fixed at 1.2.8. thanks!
Reply
#14
(2014-01-20, 06:48)aural Wrote: Any chance to let this wonderful add on work on V13? Thank you!

It works on V13. source code of current version here: http://xbmc-addons-chinese.googlecode.co...d.chinese/
Reply
#15
v2.0.0 test code here: https://github.com/taxigps/script.module...rd.chinese
Reply

Logout Mark Read Team Forum Stats Members Help
[RELEASE] Chinese keyboard addon module0