Skip to content

Commit

Permalink
Write-FormatViewExpression: Support for localization (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
StartAutomating committed Apr 17, 2022
1 parent d4ef9c3 commit 8ec38ae
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Write-FormatViewExpression.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 <NewLine /> element. All other parameters are ignored.
[Parameter(Mandatory=$true,ParameterSetName='NewLine',ValueFromPipelineByPropertyName=$true)]
[switch]
Expand Down Expand Up @@ -150,7 +165,11 @@

if ($Text) {
"<Text>$([Security.SecurityElement]::Escape($Text))</Text>"
} else {
}
elseif ($AssemblyName -and $BaseName -and $ResourceID) {
"<Text AssemblyName='$AssemblyName' BaseName='$BaseName' ResourceId='$ResourceID' />"
}
else {
if ($Count -gt 1 -and $PSBoundParameters.ContainsKey('ScriptBlock')) {
$ScriptBlock = [ScriptBlock]::Create("`$n = `$number = $n;
$($PSBoundParameters['ScriptBlock'])
Expand Down

0 comments on commit 8ec38ae

Please sign in to comment.