Cross-platform client for translating text in the console, uses API Google (edded public free token), MyMemory and DeepLX (no token required).
MIT License
PowerShell module for free text translation using Google (public serverless on Vercel), DeepLX (public serverless on Vercel), MyMemory and Reverso providers via REST API
(no token required).
This module also automates the process of installing, updating, managing and working with the DeepLX server.
The module can be very useful if you spend a lot of time in the console or do not want to use a browser or third-party applications to translate text.
The work of the module is automated and free of charge, no additional intervention in the work of the module is required from you.
The process of determining the language for the LanguageSource
and LanguageTarget
parameters is automated between Russian and English. This process can be automated for any language.
This module also automates the process of launching the DeepLX server for local or remote use on other machines (e.g. those without Internet access).
Tested on Windows 10/11 and Ubuntu Server 20.04+ using PowerShell Core version 7.2 +.
Register-PSRepository -Name "NuGet" -SourceLocation "https://www.nuget.org/api/v2" -InstallationPolicy Trusted
Install-Module Console-Translate -Repository NuGet
Register-PSRepository -Name "lifailon" -SourceLocation "https://www.myget.org/F/lifailon/api/v2" -InstallationPolicy Trusted
Install-Module Console-Translate -Repository lifailon
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser && irm https://get.scoop.sh | Invoke-Expression
scoop bucket add Console-Translate https://github.com/Lifailon/Console-Translate.git
scoop install Console-Translate
scoop uninstall Console-Translate && scoop bucket rm Console-Translate
Deployment a module from the GitHub repository with a single command in the console:
Invoke-Expression(New-Object Net.WebClient).DownloadString("https://raw.githubusercontent.com/Lifailon/Console-Translate/rsa/deploy-module.ps1")
Import-Module Console-Translate
Get-Command -Module Console-Translate
CommandType Name Version Source
----------- ---- ------- ------
Function Get-Translate 0.3 Console-Translate
Function Install-DeepLX 0.3 Console-Translate
Function Start-DeepLX 0.3 Console-Translate
Function Stop-DeepLX 0.3 Console-Translate
Function Get-DeepLX 0.3 Console-Translate
Dependence: PowerShell Core
sudo apt-get install -y wget apt-transport-https software-properties-common
curl -s https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -o packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y powershell
pwsh -c 'Invoke-Expression(New-Object Net.WebClient).DownloadString("https://raw.githubusercontent.com/Lifailon/Console-Translate/rsa/deploy-module.ps1")'
Run the PowerShell interpreter using the pwsh
command. All commands for Windows are identical for execution in Linux by PowerShell Core.
The parameters limit the use of this cmdlet to two languages: English (en
) and Russian (ru
), for which there is automatic detection of the source language at the PowerShell code level.
Get-Translate "Module for text translation" -Provider Google
Get-Translate " "
Text translation module
Get-Translate "Hello " -LanguageSelected
Language Source: EN
Language Target: RU
Get-Translate " world" -LanguageSelected
Language Source: RU
Language Target: EN
Hello world
Get-Translate "Module for text translation" -Provider DeepL
Get-Translate "Module for text translation" -Provider MyMemory
.
Get-Translate "Module for text translation" -Provider Reverso
Supported languages from the drop-down list (encoded in the parameter) with support for automatic language detection at the api level.
Abbr | EN (RU) |
---|---|
EN |
English () |
RU |
Russian () |
JA |
Japanese () |
ZH |
Chinese () |
KO |
Korean () |
TR |
Turkish () |
UK |
Ukrainian () |
SK |
Slovak () |
SL |
Slovenian () |
LT |
Lithuanian () |
PL |
Polish () |
CS |
Czech () |
FI |
Finnish () |
ET |
Estonian () |
BG |
Bulgarian () |
DA |
Danish () |
LV |
Latvian () |
IT |
Italian () |
ES |
Spanish () |
FR |
French () |
PT |
Portuguese () |
RO |
Romanian () |
SV |
Swedish () |
HU |
Hungarian () |
EL |
Greek () |
NB |
Norwegian Bokmal () |
NL |
Dutch () |
DE |
German () |
ID |
Indonesian () |
AR |
Arabic () |
Install or update the DeepLX server executable for local or remote use with a single command (for Windows and Linux):
Install-DeepLX
When calling the module, if the remote server address is not specified (parameter: Server), the local server is started for the time of sending a request and receiving a response, after which the server stops, it allows not to keep network socket open.
# Russian to English
Get-DeepLX " "
Help translate a text
Help translate the text
Help me translate a text
# English to Russian
Get-DeepLX "Help translate text" ru
# English to Japanese
Get-DeepLX "Help translate text" ja
# Japanese to Russian
Get-DeepLX "" ru
.
.
.
# English to Chinese
Get-DeepLX "Help translate text" zh
# English to Turkish
Get-DeepLX "Help translate text" tr
Metni evirmeye yardmc olun
Metin evirisine yardm edin
Metni evirmeye yardm et
If you need to use a single server to handle all requests from multiple clients on the network, you can use this construct:
Start the server:
Start-DeepLX -Job
Start-DeepLX -Status
Running
This will allow you to run the server in the background. The default port is 1188
and the api token (this key is used for authorization on the server) is 7777777777
.
Execute a requests to the remote server:
Get-DeepLX -Text " " -Server 192.168.3.100
Translation of text on a remote server
Translate a text on a remote server
Translating text on a remote server
Get-DeepLX -Text " " -Server 192.168.3.100 -Port 1188 -Token "7777777777"
Translation of text on a remote server
Translate a text on a remote server
Translating text on a remote server
Server stop:
Stop-DeepLX
Start-DeepLX -Status
Not running
To speed up the process of interacting with the module, program hotkeys in Windows Terminal:
Open the JSON configuration file
in Application Settings and add or edit the Actions
block:
"actions":
[
{
"command":
{
"action": "copy",
"singleLine": false
},
"keys": "ctrl+c" // default: ctrl+shift+c
},
{
"command": "paste",
// We save the classic interpreter insertion via ctrl+v, without forcing you to execute the code line by line
"keys": "ctrl+shift+v" // default: ctrl+v
},
{
"command":
{
"action": "sendInput",
"input": "\u0001\u001b[3~Get-Translate -Provider Google ''\u001b[D"
},
"keys": "ctrl+g"
},
{
"command":
{
"action": "sendInput",
"input": "\u0001\u001b[3~Get-Translate -Provider Google -Text $(Get-Clipboard)\u001b[D\r"
},
"keys": "ctrl+shift+g"
}
]
The first two command blocks are responsible for redefining the copy and paste keys from the clipboard (use Ctrl+C
and Ctrl+V
as in the classic PowerShell terminal, getting rid of intrusive warnings about pasting text and line-by-line execution of commands).
The third parameter is responsible for processing the Ctrl+G
key press, which preliminarily clears the input line, after which it causes the text to be inserted: Get-Translate -Provider Google ''
and moves the cursor to the center of the quotation marks, which allows you to enter text and call translation immediately after pressing . The last command does the same thing, but pastes text from the clipboard (using the built-in Get-Clipboard
command) and calls execution to instantly translate the text when you press Ctrl+Shift+G
.
Similarly, you can assign the translation call for DeepL/DeepLX, MyMemory and Reverso to other key combinations.
You can use a module that dont use an API, instead using Selenium via .NET to PowerShell for compose requests directly to the application:
Automated deployment and updating of all dependencies: Deploy Selenium: Deploy-Selenium
Repository: Selenium-Modules
Module: Get-Translate