#translation #tauri #popup #wry #fanyi

app popup-translation

🧼 A popup translation tool

1 unstable release

0.2.2 Feb 14, 2023

#7 in #popup

36 downloads per month

MIT license

4.5MB
386 lines

Popup translation

通过 wry 打开一个 webview 窗口,然后打开某个翻译平台的网页翻译内容,并通过 js 代码屏蔽掉不需要的内容,专注于翻译内容本身。

img.png

💫 Features

  1. 利用 wry 提供的网页视图功能实现的弹窗功能
  2. 从剪贴板读取文本并翻译
  3. 从命令行传入文本进行翻译
  4. 支持多种翻译平台
    1. Bing
    2. Youdao
    3. YouGlish
    4. Dict

🚀 Getting Started

cargo install --git https://github.com/fzdwx/popup-translation

# 命令行直接设置翻译文本,只运行一次
fanyi hello
fanyi -p youdao 你好

# 守护模式,可以一直翻译,`ctrl+shift+c` 打开窗口
fanyi

# 覆盖快捷键,使用 `alt+s` 打开窗口
fanyi --show=alt+s

# 设置窗口显示位置,默认为鼠标附近
fanyi --position=100,100

fanyi --help

🕹️ Integrated

nvim

map("n", "<leader>fy", function()
    local word = vim.fn.expand("<cWORD>")
    local cmd = { "fanyi", word }
    vim.fn.jobstart(cmd, { detach = true })
end, { desc = "qwe" })

gif

🦹 TODO

  • 弹窗位置选项(当前是固定获取鼠标附近)
    • e.g: top_left, top_center, top_right, center ...
  • 热键
    • open
      • 从粘贴板读取数据
      • 读取鼠标选择的数据
        • Linux
        • Windows
        • MacOS
    • close
  • 全程只使用一个 webview

📖 Thanks

  1. manateelazycat - popweb
  2. wry

License

MIT

Dependencies

~15–56MB
~813K SLoC