开发者

How to localize SharePoint publishing page title

开发者 https://www.devze.com 2023-02-08 21:49 出处:网络
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\", \"mylayo

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消