powershellwindows-10currentuicultureuiculture

PowerShell UICulture vs. Windows setting


During my tinkering with PS 5.1 under Win 10, related to the objective of question Fully change language (including Culture) for the current PowerShell session, I came across a couple of related questions.

  1. Where is the Windows setting associated with the UICulture? I did not find the "Keyboard and Languages" tab of the "Region and Language" control panel as indicated here.

  2. Can this be persistently changed from within PS? All I found so far only persist in a session.


The setting Settings -> Time and Language -> Language -> Windows display language shows "Español (España)", and PS gives

> Get-UICulture ; [System.Threading.Thread]::CurrentThread.CurrentUICulture ; [CultureInfo]::CurrentUICulture ;
LCID             Name             DisplayName
----             ----             -----------
1033             en-US            English (United States)
1033             en-US            English (United States)
1033             en-US            English (United States)

without any intervening changes and in a session just launched.


Solution

  • In .NET, cultures (System.Globalization.CultureInfo) are used to control two related, but independent aspects of (human) culture-specific for-display representations:


    Switching to a different culture:

    Interactive (GUI) methods, which are invariably persistent, for the current user:

    Note: These settings apply to .NET and non-.NET applications equally, assuming these applications are designed to respect the user's regional formats (locale, culture) and display language (UI culture) and come with language-specific resources.
    By contrast, making in-session-only changes via [cultureinfo]::CurrentUICulture / [cultureinfo]::CurrentCulture (see below) applies to .NET applications only.

    Programmatic methods: