PowerShell icon indicating copy to clipboard operation
PowerShell copied to clipboard

META: What are the features needed to improve PowerShell localization

Open JamesWTruher opened this issue 2 years ago • 1 comments

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

JamesWTruher avatar Jun 26 '23 16:06 JamesWTruher

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)

MartinGC94 avatar Jun 26 '23 21:06 MartinGC94

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.

hyke123 avatar Jan 23 '24 09:01 hyke123