我有一个使用SharePoint api的函数,因此公开了方法SPUtility.GetLocalizedString。
我还确定了uint语言编号1033(英语)和1036(法语)作为参数之一。
[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
$en = 1033
$fr = 1036
$str = "$Resources:docliblist"
$resx = "core"
$locstr = [Microsoft.SharePoint.Utilities.SPUtility]::GetLocalizedString($str, $resx, $en)
$locstr
$locstr = [Microsoft.SharePoint.Utilities.SPUtility]::GetLocalizedString ("$Resources:doclibList", "core", $fr)
$locstr
当我运行该函数时,$ locstr为空。不为空,为空。
另外,当我以这种方式使用函数时:
$str = "$Resources:core, docliblist"
$locstr = [Microsoft.SharePoint.Utilities.SPUtility]::GetLocalizedString($str, $null, $en)
我得到一个返回值'docliblist'
现在,虽然我可以从resx文件中取出所需的内容并放入我自己的配置文件中,但对于为什么此方法不起作用我感到困惑。如果有人有任何建议,我将不胜感激。
谢谢。
*编辑
您更改引号的目的是什么?
最佳答案
如果$Resources
不是powershell变量,则需要转义'$'
。尝试这种方式:
$str = "`$Resources:docliblist"
关于sharepoint - Powershell:使用SharePoint API,GetLocalizedString不返回任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9809128/