mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-03-25 05:26:47 +01:00
Update translate-files.ps1
This commit is contained in:
parent
baccfcf990
commit
af856fe2f9
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user