powershell:改变当前会话的文化 [英] powershell : changing the culture of current session

查看:49
本文介绍了powershell:改变当前会话的文化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 windows vista 上使用 powershell.如何更改当前会话的文化?我的计算机的文化是 tr-TR,所以我收到土耳其语的错误消息.我想改成英文?

I am using powershell on windows vista. How do I change the culture of current session? My computer's culture is tr-TR so I am getting the error messages on Turkish. I would like to change to EN?

有机会吗?

推荐答案

看这里:http://blogs.msdn.com/b/powershell/archive/2006/04/25/583235.aspx

这里:http://poshcode.org/2226:

function Set-Culture([System.Globalization.CultureInfo] $culture)
{
    [System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture
    [System.Threading.Thread]::CurrentThread.CurrentCulture = $culture
}

<小时>

附加信息

要查找哪些值可用于 $culture:

To find which values can be used for $culture:

  • 这将为您提供一个文化类型列表:

  • This will give you a list of Culture Types:

[Enum]::GetValues([System.Globalization.CultureTypes])

  • 选择上述类型之一(例如 AllCultures),您可以列出该类型的可用值:

  • Selecting one of the above types (e.g. AllCultures) you can then list the available values of that type:

    [System.Globalization.CultureInfo]::GetCultures( [System.Globalization.CultureTypes]::AllCultures )
    

  • 然后,您可以使用您感兴趣的文化的名称或编号和 GetCultureInfo 方法来检索您想要的值:

  • You can then use the Name or Number of the culture you're interested in with the GetCultureInfo method to retrieve the value you're after:

    $culture = [System.Globalization.CultureInfo]::GetCultureInfo(1033)
    $culture = [System.Globalization.CultureInfo]::GetCultureInfo('en-US')
    

  • 注意:由于隐式转换,您可以将区域性名称或数字(即作为字符串或整数)传递给 Set-Culture 方法,该方法将自动转换为预期的 CultureInfo 值.

    NB: Thanks to implicit conversion, you could just pass the culture name or number (i.e. as a string or integer) to the Set-Culture method which would automatically be converted to the expected CultureInfo value.

    这篇关于powershell:改变当前会话的文化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆