PowerShell/Scripts/translate-file.ps1

30 lines
892 B
PowerShell
Raw Normal View History

2021-02-09 19:30:45 +01:00
#!/bin/powershell
2020-12-29 15:14:21 +01:00
<#
.SYNTAX ./translate-file.ps1 [<file>] [<source-lang>] [<target-lang>]
.DESCRIPTION translates the given file from source to target language.
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
2020-12-12 16:18:46 +01:00
2021-02-12 12:26:40 +01:00
param($File = "", $SourceLanguage = "", $TargetLanguage = "")
2020-12-29 15:14:21 +01:00
2020-12-12 16:18:46 +01:00
try {
2021-02-12 12:24:41 +01:00
$PathToRepo = "$PSScriptRoot/.."
2021-02-12 12:26:40 +01:00
if ($File -eq "" ) {
$File = read-host "Enter path to file"
2020-12-25 11:30:43 +01:00
}
if ($SourceLanguage -eq "" ) {
$SourceLanguage = read-host "Enter language of this file"
}
if ($TargetLanguage -eq "" ) {
$TargetLanguage = read-host "Enter language to translate to"
}
2021-02-12 12:26:40 +01:00
Start-Process -FilePath "$PathToRepo/Data/trans" -ArgumentList "-i $File -s $SourceLanguage -t $TargetLanguage -e google -brief" -NoNewWindow -Wait
2020-12-12 16:18:46 +01:00
exit 0
} catch {
2020-12-25 11:30:43 +01:00
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2020-12-12 16:18:46 +01:00
exit 1
}