2013-02-26 107 views
3

我已将语言包安装到SharePoint 2010.如何在Sharepoint 2010中自定义列表的语言视图

我已在Visual Studio中创建项目SharePoint 2010。在项目中,我创建了一个功能,并增加资源文件RESX和功能接收方法:

public override void FeatureActivated(SPFeatureReceiverProperties properties) 

当我创建列表RESX文件的翻译是不适用的情况变化的语言。这是我的代码示例,但它不工作:

   var listView = new StringCollection(); 

       listView.Add("$Resources:lblAccountName"); // error 

       listView.Add("$Resources:lblFullName"); // error 

       list.Views.Add("view1", listView, string.Empty, 30, true, true); 

       list.Update(); 

请问您能帮我吗?

+0

什么确切的错误是什么?如果可能,你能提供一个消息和堆栈跟踪吗?谢谢 – 2013-02-26 10:52:59

回答

0

我总是会创建一个ResourceManager对象来从本地化资源文件中检索字符串。例如。

public static ResourceManager rm = new ResourceManager("MyProject.SharePointRoot.Resources.LanguageLocalization", typeof(MyProject.SharePointRoot.Resources.LanguageLocalization).Assembly); 

注意:“LanguageLocalization”是我的资源resx文件的名称。

然后:

  var listView = new StringCollection(); 

      listView.Add(rm.GetString("lblAccountName")); 

      listView.Add(rm.GetString("lblFullName")); 

      list.Views.Add("view1", listView, string.Empty, 30, true, true); 

      list.Update(); 

在这里看到更多的信息http://msdn.microsoft.com/en-us/library/system.resources.resourcemanager.aspx

相关问题