Add translate-file.ps1

This commit is contained in:
Markus Fleschutz
2021-04-08 08:39:13 +02:00
parent 1907062856
commit b2e571ec15
5 changed files with 5730 additions and 22 deletions

26
Scripts/translate-file.ps1 Executable file
View File

@ -0,0 +1,26 @@
#!/bin/powershell
<#
.SYNTAX ./translate-file.ps1 [<file>] [<source-lang>] [<target-lang>]
.DESCRIPTION translates the given text file into another language and prints the result.
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param($File = "", $SourceLang = "", $TargetLang = "")
if ($File -eq "" ) { $File = read-host "Enter path to file" }
if ($SourceLang -eq "" ) { $SourceLang = read-host "Enter language used in this file" }
if ($TargetLang -eq "" ) { $TargetLang = read-host "Enter language to translate to" }
try {
$PathToRepo = "$PSScriptRoot/.."
$Engine = "google" # aspell | google | bing | spell | hunspell | apertium | yandex
start-process -filePath "$PathToRepo/Data/trans" -argumentList "-i $File -s $SourceLang -t $TargetLang -e $Engine -brief" -noNewWindow -wait
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}