Skip to content

META: What are the features needed to improve PowerShell localization  #19860

Open

Description

Summary of the new feature / enhancement

We should think through the features that PowerShell needs to improve its localization story.
#14992
#17740
#8219
#6217
#5390
#666

these are some of the issues that are related to this

Proposed technical implementation details (optional)

No response

Activity

  1. added
    Issue-Enhancementthe issue is more of a feature request than a bug
    Issue-Metaan issue used to track multiple issues
    Needs-TriageThe issue is new and needs to be triaged by a work group.
    on Jun 26, 2023
  2. MartinGC94 commented on Jun 26, 2023

    @MartinGC94
    Contributor

    A common argument people use against using localized software is that it makes it harder to look up errors and I think that's a valid point. I think there are 2 changes that could be made to address this complaint:

    1. A preference variable to set the desired language for errors (People may still want localized dates and numbers so it shouldn't just change the whole culture to the specified language).
    2. A command to convert an error record to a different culture, like: Get-Error | Get-LocalizedError -TargetCulture en-US.

    Some people may also want to run PowerShell in English but keep the OS localized but there's no easy way to change the culture on the fly. The following reflection code seems to do the trick but a proper command would be better:

    $culture = [System.Globalization.CultureInfo]::CreateSpecificCulture("en-US")
    $assembly = [System.Reflection.Assembly]::Load("System.Management.Automation")
    $type = $assembly.GetType("Microsoft.PowerShell.NativeCultureResolver")
    $field = $type.GetField("m_uiCulture", [Reflection.BindingFlags]::NonPublic -bor [Reflection.BindingFlags]::Static)
    $field.SetValue($null, $culture)
    
  3. hyke123 commented on Jan 23, 2024

    @hyke123

    Hi all, could you please share with me how I can get the DLL for other language resources in PowerShell.SDK ? I am using the powershell.sdk 7.2.0 for my c# program, Thanks.

  4. virtual-panda commented on Jun 21, 2026

    @virtual-panda

    A common argument people use against using localized software is that it makes it harder to look up errors and I think that's a valid point. I think there are 2 changes that could be made to address this complaint:

    1. A preference variable to set the desired language for errors (People may still want localized dates and numbers so it shouldn't just change the whole culture to the specified language).
    2. A command to convert an error record to a different culture, like: Get-Error | Get-LocalizedError -TargetCulture en-US.

    Some people may also want to run PowerShell in English but keep the OS localized but there's no easy way to change the culture on the fly. The following reflection code seems to do the trick but a proper command would be better:

    $culture = [System.Globalization.CultureInfo]::CreateSpecificCulture("en-US")
    $assembly = [System.Reflection.Assembly]::Load("System.Management.Automation")
    $type = $assembly.GetType("Microsoft.PowerShell.NativeCultureResolver")
    $field = $type.GetField("m_uiCulture", [Reflection.BindingFlags]::NonPublic -bor [Reflection.BindingFlags]::Static)
    $field.SetValue($null, $culture)
    

    That's a good idea. While localized error message displayed, we can drop a message in English, so that everyone can search and realize the error.

    I think we can learn from WindowsPowerShell 5.1 .

    PS C:\Users\myname> Get-ChildItem ./missing -ErrorAction Continue
    Get-ChildItem : Cannot find path 'C:\Users\myname\missing' because it does not exist.
    At line:1 char:1
    + Get-ChildItem ./missing -ErrorAction Continue
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (C:\Users\myname\missing:String) [Get-ChildItem], ItemNotFoundException
        + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

    in a Chinese environment, it will display:

    PS C:\Users\myname> Get-ChildItem ./missing -ErrorAction Continue
    Get-ChildItem : 无法找到路径 'C:\Users\Jerry\myname' 因为路径不存在
    位于 行:1 字符:1
    + Get-ChildItem ./missing -ErrorAction Continue
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (C:\Users\myname\missing:String) [Get-ChildItem], ItemNotFoundException
        + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

    As you see, the error message contains original command, localized error message, and original error info in English, but it is too complex. In PowerShell7, the detaild error message was removed, but we can bring it back as this:

    PS C:\Users\myname> Get-ChildItem ./missing -ErrorAction Continue
    Get-ChildItem : 无法找到路径 'C:\Users\Jerry\myname' 因为路径不存在
    Details:
        + Get-ChildItem : Cannot find path 'C:\Users\myname\missing' because it does not exist.
        + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

    In Visual Studio, errors , warings and more things was displayed in your system language, so when I ask something in Github or other non-Chinene community, I must translate my error into English. We actually need a better way to break the language barrier while making softwares localized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Issue-Enhancementthe issue is more of a feature request than a bugIssue-Metaan issue used to track multiple issuesNeeds-TriageThe issue is new and needs to be triaged by a work group.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions