How does one localize the page title of a SharePoint publishing page? I am provisioning it like:
PublishingPage newPage =开发者_Go百科 publishingWeb.GetPublishingPages().Add("mypage.aspx", "mylayout.aspx");
newPage.Title = "$Resources:MYRESX,MyPage_PageTitle";
newPage.Update();
When I provision this page, the title shows up literally, $Resources:MYRESX,MyPage_PageTitle
, instead of SharePoint looking up the string. So, I guess my assumption is wrong that SharePoint would look the string up. Or I have the syntax wrong.
I am already referencing MYRESX
in other places; I am sure the resource file / string is accessible.
I have the exact same issue for webpart titles as well, so hopefully a unified solution exists for both scenarios.
Try SPUtility.GetLocalizedString:
newPage.Title =
SPUtility.GetLocalizedString(
"$Resources:MyPage_PageTitle",
"MYRESX",
web.Language);
精彩评论