Skip to content

Commit

Permalink
(GH-741) Ensure CultureInfo with PowerShell Host
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ferventcoder committed May 25, 2016
1 parent 93a42d6 commit 152d83e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Expand Up @@ -58,5 +58,4 @@ if ($env:ChocolateyExitCode -ne $null -and $env:ChocolateyExitCode -ne '') {
$exitCode = $env:ChocolateyExitCode
}


Exit $exitCode
6 changes: 4 additions & 2 deletions src/chocolatey/infrastructure/powershell/PoshHost.cs
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 152d83e

Please sign in to comment.