Update translate-files.ps1

This commit is contained in:
Markus Fleschutz 2023-06-12 11:36:56 +02:00
parent baccfcf990
commit af856fe2f9

View File

@ -2,9 +2,9 @@
.SYNOPSIS
Translates text files
.DESCRIPTION
This PowerShell script translates text files into any supported language.
.PARAMETER FilePattern
Specifies the file pattern
This PowerShell script translates text files into multiple languages.
.PARAMETER filePattern
Specifies the file pattern of the text file(s) to be translated
.EXAMPLE
PS> ./translate-files C:\Temp\*.txt
.LINK
@ -13,7 +13,7 @@
Author: Markus Fleschutz | License: CC0
#>
param([string]$FilePattern = "")
param([string]$filePattern = "")
function DetectSourceLang { param([string]$Filename)
if ("$Filename" -like "*Deutsch*") { return "de" }
@ -32,10 +32,10 @@ function TranslateFilename { param([string]$Filename, [string]$SourceLang, [stri
}
try {
if ($FilePattern -eq "" ) { $FilePattern = read-host "Enter the file pattern" }
if ($filePattern -eq "" ) { $filePattern = Read-Host "Enter the file pattern of the text file(s) to be translated" }
$TargetLanguages = "ar","zh","fr","de","hi","ga","it","ja","ko","pt","ru","es"
$SourceFiles = get-childItem -path "$FilePattern"
$SourceFiles = Get-ChildItem -path "$filePattern"
foreach($SourceFile in $SourceFiles) {
$SourceLang = DetectSourceLang $SourceFile
foreach($TargetLang in $TargetLanguages) {