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