Skip to content

Commit

Permalink
Fix binding variable
Browse files Browse the repository at this point in the history
  • Loading branch information
johlju committed Jan 20, 2024
1 parent eabe276 commit d016288
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions source/Public/Get-LocalizedData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,18 @@ function Get-LocalizedData
$localizedData = Microsoft.PowerShell.Utility\Import-LocalizedData @PSBoundParameters
}

if ($PSBoundParameters.ContainsKey('BindingVariable') -and $localizedData)
if ($PSBoundParameters.ContainsKey('BindingVariable'))
{
Write-Debug -Message ('Binding variable ''{0}'' to localized data.' -f $BindingVariable)
# The command we called returned the localized data in the binding variable.
$boundLocalizedData = Get-Variable -Name $BindingVariable -ValueOnly -ErrorAction 'Ignore'

# Bringing the variable to the parent scope
Set-Variable -Scope 1 -Name $BindingVariable -Force -ErrorAction 'SilentlyContinue' -Value $localizedData
if ($boundLocalizedData)
{
Write-Debug -Message ('Binding variable ''{0}'' to localized data.' -f $BindingVariable)

# Bringing the variable to the parent scope
Set-Variable -Scope 1 -Name $BindingVariable -Force -ErrorAction 'SilentlyContinue' -Value $boundLocalizedData
}
}
else
{
Expand Down

0 comments on commit d016288

Please sign in to comment.