Added translate-file.ps1

This commit is contained in:
Markus Fleschutz
2020-12-12 15:18:46 +00:00
parent d9423bf219
commit 7dd4a9058e
3 changed files with 5720 additions and 0 deletions

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

@ -0,0 +1,26 @@
#!/snap/bin/powershell
# Syntax: ./translate-file.ps1 [<file>]
# Description: translates the given file from source to target language.
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$SourceFile, [string]$SourceLanguage, [string]$TargetLanguage)
if ($SourceFile -eq "" ) {
$SourceFile = read-host "Enter path to file"
}
if ($SourceLanguage -eq "" ) {
$SourceLanguage = read-host "Enter source language"
}
if ($TargetLanguage -eq "" ) {
$TargetLanguage = read-host "Enter target language"
}
try {
./trans -i $SourceFile -s $SourceLanguage -t $TargetLanguage -e google -brief
exit 0
} catch {
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}