Open a terminal:

Step 1: apt-get install scim scim-gtk2-immodule scim-modules-socket scim-modules-table scim-pinyin scim-tables-zh scim-input-pad

Step 2: Goto /etc/X11/Xsession.d and create a file named 95xinput

Step 3: Type: export XMODIFIERS=@im=SCIM
: export GTK_IM_MODULE="scim"

Step 4: goto to terminal and type chmod 755 /etc/X11/Xsession.d/95xinput
(necessary for ubuntu that does not run as root)

Step 5: Reboot your system. Press Ctrl+Space to toggle scim