Install fcitx5 with the following commands:
sudo pacman -S fcitx5-im
sudo pacman -S fcitx5-chinese-addons fcitx5-rime
Add the following config lines into /etc/environment:
# /etc/environment
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
XMODIFIERS=@im=fcitx
SDL_IM_MODULE=fcitx
Reboot the system.