From 152d83ef960ddb2d88998d19c697edcab6f0be35 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Tue, 24 May 2016 22:03:23 -0500 Subject: [PATCH] (GH-741) Ensure CultureInfo with PowerShell Host When using the built-in posh host, the culture information that is returned should be the user's culture info, so that gathering the LCID for language settings in packages works appropriately. Without this fix, everyone will be given the invariant culture (127), which could cause problems across every package that detects locale. --- src/chocolatey.resources/helpers/chocolateyScriptRunner.ps1 | 1 - src/chocolatey/infrastructure/powershell/PoshHost.cs | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/chocolatey.resources/helpers/chocolateyScriptRunner.ps1 b/src/chocolatey.resources/helpers/chocolateyScriptRunner.ps1 index 0cc03ce2b7..5085d69092 100644 --- a/src/chocolatey.resources/helpers/chocolateyScriptRunner.ps1 +++ b/src/chocolatey.resources/helpers/chocolateyScriptRunner.ps1 @@ -58,5 +58,4 @@ if ($env:ChocolateyExitCode -ne $null -and $env:ChocolateyExitCode -ne '') { $exitCode = $env:ChocolateyExitCode } - Exit $exitCode \ No newline at end of file diff --git a/src/chocolatey/infrastructure/powershell/PoshHost.cs b/src/chocolatey/infrastructure/powershell/PoshHost.cs index 302e1f5cdc..a1f3559548 100644 --- a/src/chocolatey/infrastructure/powershell/PoshHost.cs +++ b/src/chocolatey/infrastructure/powershell/PoshHost.cs @@ -26,6 +26,8 @@ public class PoshHost : PSHost private readonly ChocolateyConfiguration _configuration; private readonly Guid _hostId = Guid.NewGuid(); private readonly PoshHostUserInterface _psUI; + private readonly CultureInfo _cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; + private readonly CultureInfo _cultureUiInfo = System.Threading.Thread.CurrentThread.CurrentUICulture; private bool _isClosing; @@ -60,12 +62,12 @@ public override void SetShouldExit(int exitCode) public override CultureInfo CurrentCulture { - get { return CultureInfo.InvariantCulture; } + get { return _cultureInfo; } } public override CultureInfo CurrentUICulture { - get { return CultureInfo.InvariantCulture; } + get { return _cultureUiInfo; } } public override Guid InstanceId