Kodi Community Forum
[RELEASE] Chinese keyboard addon module - Printable Version

Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
--- Thread: [RELEASE] Chinese keyboard addon module (/showthread.php?tid=98194)

Pages: 1 2


[RELEASE] Chinese keyboard addon module - taxigps - 2011-03-31

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]


- eemm - 2011-04-02

thank you very much


Using ChineseKeyboard in search folder - d744000 - 2011-11-28

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



Patch for Dharma xmbc release - cmeng - 2012-01-07

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-chinese/issues/detail?id=10

For xbmc Eden release, the fix is not working as explained in:
http://code.google.com/p/xbmc-addons-chinese/issues/detail?id=13


- taxigps - 2012-02-05

Support Eden now.


- StoVine - 2012-02-15

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


RE: [RELEASE] Chinese keyboard addon module (Dharma/Eden) - agamjl - 2012-10-20

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?


RE: [RELEASE] Chinese keyboard addon module (Dharma/Eden) - taxigps - 2012-12-15

(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.


RE: [RELEASE] Chinese keyboard addon module (Dharma/Eden) - moto_v70 - 2012-12-15

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


RE: [RELEASE] Chinese keyboard addon module (Dharma/Eden) - taxigps - 2012-12-16

(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.


RE: [RELEASE] Chinese keyboard addon module (Dharma/Eden) - ulion - 2012-12-27

Bug:
Wordsperpage not used correctly. When final get the word user choosed, should *(wordperpage +1)


RE: [RELEASE] Chinese keyboard addon module (Dharma/Eden) - aural - 2014-01-20

Any chance to let this wonderful add on work on V13? Thank you!


RE: [RELEASE] Chinese keyboard addon module (Dharma/Eden) - taxigps - 2014-02-05

(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!


RE: [RELEASE] Chinese keyboard addon module (Dharma/Eden) - taxigps - 2014-02-05

(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.com/svn/addons/eden_src/script.module.keyboard.chinese/


RE: [RELEASE] Chinese keyboard addon module (Dharma/Eden) - taxigps - 2014-02-08

v2.0.0 test code here: https://github.com/taxigps/script.module.keyboard.chinese