Skip to content

Get-Culture and $PSCulture do not (consistently) reflect in-session changes to another culture #3831

@mklement0

Description

@mklement0

Note: Perhaps this is by design (although there's at least a buggy inconsistency), given that there's currently no PowerShell mechanism for in-session switching to another culture. If so, it should at least be documented.

Steps to reproduce

[pscustomobject] @{ Test = 'initial'; Name = (Get-Culture).Name}
[cultureinfo]::currentculture = 'fr-FR'; [pscustomobject] @{ Test = '$PSCulture'; Name =$PSCulture }, [pscustomobject] @{ Test = 'GetCulture'; Name = (Get-Culture).Name }, [pscustomobject] @{ Test = '$host.CurrentCulture'; Name = $host.CurrentCulture.Name }, [pscustomobject] @{ Test = '.NET'; Name = [cultureinfo]::currentculture.name }

Note:

  • If you try the above interactively, be sure to execute the 2nd line above on a single line.
  • The output below:
    • assumes that en-US is the initial culture at session startup time.
    • differs between PowerShell Core and Windows PowerShell: in Core, Get-Culture and $host.CurrentCulture reflect the switch, but $PSCulture doesn't, whereas in Windows PowerShell none of the PS cmdlets/properties do.

Expected behavior

Test                 Name 
----                 ---- 
initial              en-US
$PSCulture           fr-FR
GetCulture           fr-FR
$host.CurrentCulture fr-FR
.NET                 fr-FR

Actual behavior

  • PowerShell Core: Windows, macOS, Ubuntu
Test                 Name 
----                 ---- 
initial              en-US
$PSCulture           en-US
GetCulture           fr-FR
$host.CurrentCulture fr-FR
.NET                 fr-FR
  • Windows PowerShell 5.1
Test                 Name 
----                 ---- 
initial              en-US
$PSCulture           en-US
GetCulture           en-US
$host.CurrentCulture en-US
.NET                 fr-FR

Environment data

PowerShell Core v6.0.0-beta (v6.0.0-beta.1) on macOS 10.12.5
PowerShell Core v6.0.0-beta (v6.0.0-beta.1) on Ubuntu 16.04.1 LTS
PowerShell Core v6.0.0-beta (v6.0.0-beta.1) on Microsoft Windows 10 Pro (64-bit; v10.0.14393)
Windows PowerShell v5.1.14393.1198 on Microsoft Windows 10 Pro (64-bit; v10.0.14393)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking-Changebreaking change that may affect usersCommittee-ReviewedPS-Committee has reviewed this and made a decisionIssue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions