@mohaiyo/translate-hub
v0.1.1
Published
Utilize the translation API or AI capabilities on the cloud platform, combined with the Alfred workflow, to achieve rapid translation and enhance your work efficiency.
Downloads
19
Maintainers
Readme
English | 中文
Platform
| Platform | supported | description | | :-------------------------: | :----------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Aliyun Translation | :white_check_mark: | The first 1 million characters per month are free for the General Edition of machine translation. Charges of 50 RMB per million characters will apply for any exceeding usage.document,price | | OpenAI | :white_check_mark: | OpenAI API Key apply | | MicroSoft Azure Translation | :x: | Translation of up to 2 million words per month is free. If you exceed 2 million words monthly, charges will apply at a rate of $10 per million words. For further details, please consult the official pricing documentation.。document | | Baidu Translation | :white_check_mark: | Provide standard version, advanced version, exclusive version of the service, complete identity authentication, enjoy a maximum of 2 million free characters per month。document | | Volcano translation | :white_check_mark: | Volcano translation is free of charge for the first 2 million characters per month, and the excess will be charged according to 49 RMB per million characters.。document |
Installation
You need Node.js 18+ and Alfred 4 or later with the paid Powerpack upgrade.
Install with NPM
npm install -g @mohaiyo/translate-hub
Install with pnpm.
pnpm install -g @mohaiyo/translate-hub
Manually
Changelog
Usage
How to set up an API platform
Open Alfred and enter trc use [openai]
. you can see the built-in platform and select the platform you want to use. the built-in platform is aliyun.
How to set the target language
Open Alfred and enter trc target [english]
. You can see the built-in target language options, select the target language you want to translate into, the built-in is English (en).
How to use the translation function
Before using, set the API KEY for the platform you want to use. How to set, please see Environment variables
Open Alfred and type tr [enter the word or statement you want to translate]
. For example: tr 谁是世界上最可爱的人儿?
Press the enter
key or the cmd C
key to copy the translated text to the clipboard.
Press the cmd L
key to display the translation in large text.
Environment Variables
| name | value | description | | :-----------------------------: | :---: | :---------------------------------------------------------------------------: | | ALIBABA_CLOUD_ACCESS_KEY_ID | | If you use Alibaba Cloud Translation, set the corresponding ACCESS KEY ID. | | ALIBABA_CLOUD_ACCESS_KEY_SECRET | | If you use Alibaba Cloud Translation, set the corresponding ACCESS KEY SECRET | | OPENAI_API_KEY | | If you use OpenAI, set the corresponding OpenAi Key | | VOCAENGINE_ACCESS_KEY_ID | | If you use Volcano Translation, set the corresponding ACCESS KEY ID | | VOCAENGINE_ACCESS_KEY_SECRET | | If you use Volcano Translation, set the corresponding ACCESS KEY SECRET | | BAIDU_APP_ID | | If you use Baidu Translation, set the corresponding APP ID | | BAIDU_APP_SECRET | | If you use Baidu Translation, set the corresponding APP SECRET |
environment variables screenshots
Hotkey
If you download the workflow, you may have to manually set the hotkeys yourself.
Screenshots
FAQ
Q: Why does the translation fail after setting the target language from the built-in language list?
The built-in languages are supported by aliyun by default. the translation languages supported by different platforms vary.
Related
- alfy - Create Alfred workflows with ease