自制简单翻译小工具
# 安装翻译软件 ``` sudo apt install copyq translate-shell rofi xclip ``` 装好之后, 测试一下效果, 发现不正常 ``` trans -e Bing :zh "hello world" hello world [ -> 简体中文 ] ``` 检查一下内核 ``` trans -V 0.9.x ``` 发现比较老, 升级一下 ``` git clone https://github.com/soimort/translate-shell cd translate-shell sudo make install ``` 成功翻译 ``` trans -e bing -b :zh "hello" 你好 ``` # 写脚本 ``` #!/bin/bash text=$(xclip -o -selection primary) if [[ "$text" =~ [一-龥] ]]; then result=$(trans -e bing -brief :en "$text") else result=$(trans -e bing -brief :zh "$text") fi echo "$text → $result" | zenity --text-info \ --title="Translation" \ --width=400 \ --height=200 ``` 在Keyboard -> Application Shortcuts 添加这个脚本, 并且设置一个快捷键, 选择并按快捷键就好了, 但是速度有点延迟, 大概1s