mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-16 17:51:28 +01:00
Update check-ps1-file.ps1 and translate-files.ps1
This commit is contained in:
parent
fb208f3814
commit
e4b9649681
@ -1,10 +1,10 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks a PowerShell file for validity
|
||||
Checks PowerShell file(s) for validity
|
||||
.DESCRIPTION
|
||||
This PowerShell script checks the given PowerShell file for validity.
|
||||
.PARAMETER pattern
|
||||
Specifies the file pattern to the PowerShell file(s) to check
|
||||
This PowerShell script checks the given PowerShell file(s) for validity.
|
||||
.PARAMETER filePattern
|
||||
Specifies the file pattern to the PowerShell file(s)
|
||||
.EXAMPLE
|
||||
PS> ./check-ps1-file *.ps1
|
||||
✔️ Valid PowerShell in myfile.ps1
|
||||
@ -14,16 +14,17 @@
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$pattern = "")
|
||||
param([string]$filePattern = "")
|
||||
|
||||
try {
|
||||
if ($pattern -eq "" ) { $path = Read-Host "Enter the file pattern to the PowerShell file(s)" }
|
||||
$files = Get-ChildItem $pattern
|
||||
if ($filePattern -eq "" ) { $path = Read-Host "Enter the file pattern to the PowerShell file(s)" }
|
||||
$files = Get-ChildItem $filePattern
|
||||
foreach ($file in $files) {
|
||||
$syntaxError = @()
|
||||
[void][System.Management.Automation.Language.Parser]::ParseFile($file, [ref]$null, [ref]$syntaxError)
|
||||
if ("$syntaxError" -ne "") { throw "$syntaxError" }
|
||||
"✔️ Valid PowerShell in $file"
|
||||
$basename = (Get-Item "$file").Basename
|
||||
"✔️ Valid PowerShell in $basename"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
@ -1,6 +1,6 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Translates text files into any supported language
|
||||
Translates text files
|
||||
.DESCRIPTION
|
||||
This PowerShell script translates text files into any supported language.
|
||||
.PARAMETER FilePattern
|
||||
@ -16,8 +16,8 @@
|
||||
param([string]$FilePattern = "")
|
||||
|
||||
function DetectSourceLang { param([string]$Filename)
|
||||
if ("$Filename" -like "*Deutsch*") { return "de" }
|
||||
if ("$Filename" -like "*English*") { return "en" }
|
||||
if ("$Filename" -like "*Deutsch*") { return "de" }
|
||||
if ("$Filename" -like "*English*") { return "en" }
|
||||
if ("$Filename" -like "*Français*") { return "fr" }
|
||||
return "unknown"
|
||||
}
|
||||
@ -27,7 +27,7 @@ function TranslateFilename { param([string]$Filename, [string]$SourceLang, [stri
|
||||
if ($SourceLang -eq "de") { $SourceLanguage = "Deutsch" }
|
||||
if ($SourceLang -eq "en") { $SourceLanguage = "English" }
|
||||
if ($SourceLang -eq "fr") { $SourceLanguage = "Français" }
|
||||
$TargetLanguage = ("$PSScriptRoot/translate-text.ps1" $SourceLanguage $SourceLang $TargetLang)
|
||||
$TargetLanguage = ("$PSScriptRoot/translate-text.ps1 $SourceLanguage $SourceLang $TargetLang")
|
||||
return $Filename.replace($SourceLanguage, $TargetLanguage)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user