zetavg / alfred-google-translate-workflow

Alfred Google Translate Workflow. Alfred 多語言翻譯 Workflow,含有拼字校正、近似詞建議功能。(Temporally broken, use https://github.com/zetavg/alfred-google-translate-workflow/pull/8)
91 stars 18 forks source link

Bundle with alfy #6

Open Yukaii opened 6 years ago

Yukaii commented 6 years ago

Refs: https://github.com/sindresorhus/alfy

zetavg commented 6 years ago

Cool XD

Yukaii commented 6 years ago

https://github.com/nikersify/alfred-polyglot

😂

zetavg commented 5 years ago

等我搞完 npm-package-to-nix 就來弄 #7 然後順便弄這個好了 XD

zetavg commented 5 years ago

https://github.com/nikersify/alfred-polyglot

😂

作者住在克拉科夫欸,今年初我還剛去過那裡 XDDDD

zetavg commented 5 years ago

把語言設定變動態的之後應該也能加個 node proxy 設定,把 #3 #5 解掉。但就需要想辦法弄個 GFW 模擬器(或是等實體入侵牆內的時候順便)(幹嘛?)。

zetavg commented 4 years ago

發現用了 alfy 變好慢,cold start 要六秒多,想放棄 Orz

Yukaii commented 4 years ago

😂 ,用過 oclif bundle 過 node.js cli tool,速度不會那麼久,可能真是 alfy 的問題

zetavg commented 4 years ago

@Yukaii 你有用 alfy 的經驗ㄇ?我懷疑是我測試時的環境問題。 但 alfy 會去尋找要用哪個 node 、還會用一個比較正規的方式來產 JSON response,所以稍微多一點時間也是正常的。

⋯⋯反正我先 setup 好 Babel 吧,之後再來看要不要用 alfy 包

Yukaii commented 4 years ago

有,以前接電話的時寫過一個分機速查表 (2018) ,不過當時我沒有特別到意識速度有問題,資料源是 local csv

Yukaii commented 4 years ago

https://github.com/sindresorhus/alfy/blob/8d61d502965427671b78c6e27d0667ed9ba5ec32/index.js#L40-L42

他 output 只是 JSON.stringify,感覺不會是瓶頸

zetavg commented 4 years ago

我又試了一次,直接用 commend line 指定 node 跑感覺差不多 (alfred_workflow_cache=/tmp/xxx node alfy-test.js),用 ./node_modules/.bin/run-node 也沒有明顯變慢了耶

現在我比較好奇他的 auto update 是怎麼做到的 XD

zetavg commented 4 years ago

我剛剛也在看這個 https://github.com/vercel/pkg "Package your Node.js project into an executable that can be run even on devices without Node.js installed"

Yukaii commented 4 years ago

pkg 我們有用 w 比較複雜的專案會需要踩點雷,static assets 的部分要照他 README 改寫

zetavg commented 4 years ago

用 vercel/pkg 包起來,跑的時候有比較快 XD

$ time ./translate auto zh-TW 'this is good translae' '繁體中文'
{"items":[{"title":"this is good translate","subtitle":"Did you mean this?","autocomplete":"this is good translate"},{"title":"這是個好翻譯","subtitle":"繁體中文","arg":"這是個好翻譯"}]}
./translate auto zh-TW 'this is good translae' '繁體中文'  0.23s user 0.05s system 32% cpu 0.842 total

$ time node ./dist/translate auto zh-TW 'this is good translae' '繁體中文'
{"items":[{"title":"this is good translate","subtitle":"Did you mean this?","autocomplete":"this is good translate"},{"title":"這是個好翻譯","subtitle":"繁體中文","arg":"這是個好翻譯"}]}
node ./dist/translate auto zh-TW 'this is good translae' '繁體中文'  0.32s user 0.24s system 46% cpu 1.213 total
zetavg commented 4 years ago

不過 pkgalfy 會出問題:

{
    "items": [
        {
            "title": "Error: spawn /snapshot/alfred-google-translate-workflow/node_modules/alfred-notifier/check.js ENOENT",
            "subtitle": "Press ⌘L to see the full error and ⌘C to copy it.",
            "valid": false,
            "text": {
                "copy": "```\nError: spawn /snapshot/alfred-google-translate-workflow/node_modules/alfred-notifier/check.js ENOENT\n```\n\n-\nundefined undefined\nAlfred undefined\ndarwin 19.5.0",
                "largetype": "Error: spawn /snapshot/alfred-google-translate-workflow/node_modules/alfred-notifier/check.js ENOENT"
            },
            "icon": {
                "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
            }
        }
    ]
}