2013-02-26 57 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

相關問題