From 8ec38ae0da8ebeb115537b4ae26c445ead45d676 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Sun, 17 Apr 2022 00:25:53 -0700 Subject: [PATCH] Write-FormatViewExpression: Support for localization (#39) --- Write-FormatViewExpression.ps1 | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Write-FormatViewExpression.ps1 b/Write-FormatViewExpression.ps1 index 295f876..dacb387 100644 --- a/Write-FormatViewExpression.ps1 +++ b/Write-FormatViewExpression.ps1 @@ -52,10 +52,25 @@ $If, # If provided, will output the provided text. All other parameters are ignored. - [Parameter(Mandatory=$true,ParameterSetName='Text',ValueFromPipelineByPropertyName=$true)] + [Parameter(Mandatory,ParameterSetName='Text',ValueFromPipelineByPropertyName=$true)] [string] $Text, + # If -AssemblyName, -BaseName, and -ResourceID are provided, localized text resources will be outputted. + [Parameter(Mandatory,ParameterSetName='LocalizedText',ValueFromPipelineByPropertyName)] + [string] + $AssemblyName, + + # If -AssemblyName, -BaseName, and -ResourceID are provided, localized text resources will be outputted. + [Parameter(Mandatory,ParameterSetName='LocalizedText',ValueFromPipelineByPropertyName)] + [string] + $BaseName, + + # If -AssemblyName, -BaseName, and -ResourceID are provided, localized text resources will be outputted. + [Parameter(Mandatory,ParameterSetName='LocalizedText',ValueFromPipelineByPropertyName)] + [string] + $ResourceID, + # If provided, will output a element. All other parameters are ignored. [Parameter(Mandatory=$true,ParameterSetName='NewLine',ValueFromPipelineByPropertyName=$true)] [switch] @@ -150,7 +165,11 @@ if ($Text) { "$([Security.SecurityElement]::Escape($Text))" - } else { + } + elseif ($AssemblyName -and $BaseName -and $ResourceID) { + "" + } + else { if ($Count -gt 1 -and $PSBoundParameters.ContainsKey('ScriptBlock')) { $ScriptBlock = [ScriptBlock]::Create("`$n = `$number = $n; $($PSBoundParameters['ScriptBlock'])